Reputation: 1407
Actually I have tried the following methods:
checkbox_visable=true;
fileList.notifyDataSetChanged();
listview.invalidate();
But it just can not recall the my specified adapter's getview()
method for each row:
@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;
}
So, any idea for me to dynamically change the UI of ListView
?
Upvotes: 2
Views: 1127
Reputation: 498
getview is called automaticaly when you scroll down the listview.
your view will be refreshed automaticaly
put a else condition in your code which will set the state of checkbox if the condition is false
if(checkbox_visable)
cb.setVisibility(View.INVISIBLE);
else
//what you want the state of the checkbox to be
i think this will work.
Upvotes: 1
Reputation: 6604
Ok then try this
listview.setAdapter(new FileList(this, R.layout.row, your data));
And in your FileList class make the construstor of your adapter like.
public FileList(Context context, int textViewResourceId, String[] objects) {
super(context, textViewResourceId, objects);
}
Hope this will help
Upvotes: 0