我正在使用Github的ViewFlow库。 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。它没有扩展,除非我滚动一点点。