1

我正在使用 Github 的 ViewFlow 库。视图流

我正在使用这个库显示四个滑动屏幕。在这些屏幕中有一个列表视图。当用户按下按钮时,此列表的数据会发生变化。我的问题是我必须滚动列表或触摸几次,然后才更新列表。因为我使用的是 Viewflow ,所以还有什么需要做的吗?

我的主要活动的相关代码如下:

    setContentView(R.layout.slidingpan);
    ViewFlow viewFlow = (ViewFlow) findViewById(R.id.viewflow);

    viewFlow.setAdapter(new screenAdapter(this));
    CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
    viewFlow.setFlowIndicator(indic);

ScreenAdapter 代码如下:

public class screenAdapter extends BaseAdapter {

private LayoutInflater mInflater;
public static Context here;


private static final int[] ids = { R.layout.multiple_screen_1, 
  R.layout.layout_vol_opportunity, R.layout.multiple_screen_3,
                                R.layout.multiple_screen_4};

public screenAdapter(Context context) 
{
    this.here = context;
    mInflater = (LayoutInflater) 
    context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}

@Override
public int getCount() {
    return ids.length;
}

@Override
public Object getItem(int position) {
    return position;
}

@Override
public long getItemId(int position) {
    return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = mInflater.inflate(R.layout.activity_main_page, null);
    }
    convertView = mInflater.inflate(ids[position], null);

    switch(ids[position])
    {
        case R.layout.multiple_screen_1:
            break;

        case R.layout.tabs_layout:      //volunteering opportunities

            break;

        case R.layout.multiple_screen_3:

            break;

        case R.layout.multiple_screen_4:
            break;
    }
    return convertView;
}
}

以下片段显示了我如何更新列表:

        projects.clear();

        boolean exit ;
        for (int i = 0 ; i < tempList.length; i++)
        {
            exit = false;
            ArrayList<Category> temp = filterList.get(i);   
            for(int j=0;j < temp.size();j++)    
            {
                for(int k = 0; k < filter.size();k++)   
                {
                    if(filter.get(k).equals(temp.get(j)))       
                    {
                        projects.add(tempList[i]);
                        exit = true;
                        break;
                    }
                }
                if(exit==true)
                    break;
            }
        }

        handle.post(new Runnable() {
            @Override
            public void run() {
                expListAdapter.notifyDataSetChanged();
            }
        });

expandiblelistview 也出现了同样的问题。除非我稍微滚动一下,否则它不会扩大。

4

0 回答 0