其实我曾尝试以下方法:如何强制listview刷新其视图?
checkbox_visable=true;
fileList.notifyDataSetChanged();
listview.invalidate();
,但它只是不记得我指定的适配器的getview()
方法为每一行:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
convertView=super.getView(position, convertView, parent);
CheckBox cb=(CheckBox) convertView.findViewById(R.id.item_cb);
if(checkbox_visable)
cb.setVisibility(View.INVISIBLE);
return convertView;
}
因此,任何想法,我来动态改变UI的ListView
?
什么是你的fileList?如果你使用ListView对象作为列表视图,那么使用listview.notifyDataSetChanged() – 2012-08-10 03:39:56
fileList是listview的适配器。我曾尝试过类似于你的想法的方式,但它失败了!ps:listview没有方法: notifyDataSetChanged()。但适配器有! – 2012-08-10 03:41:28
试试这个。 filelist = new FileList()..这个FileList应该是你的自定义适配器的自定义适配器。 listView.setAdapter(文件列表); \t \t \t \t \t \t filelist.notifyDataSetChanged(); – 2012-08-10 03:48:16