Android. ListView. Add items dynamically -
there listview uses own customarrayadapter. can't dynamically add items listview. listview component of fragment.
if(!recentitems.isempty()) { getactivity().runonuithread(new runnable() { public void run() { myfragment.listadapter.additems(recentitems); myfragment.listadapter.notifydatasetchanged(); } }); }
all new items added arraylist of customarrayadapter.
private arraylist<listitem> values; public void additems(arraylist<listitem> list) { if(build.version.sdk_int < build.version_codes.honeycomb) { for(listitem item : list) { values.add(item); } } else { values.addall(list); } }
i have read lot of suggestions till none of them worked me.
call notifydatasetchange() after add values.
Comments
Post a Comment