android - Why Auto Complete TextView is not changing the data in dynamic way? -
i have autocomplete textview suggestion. want alter suggestion info when user click button. here code
public class mainactivity extends activity { arrayadapter adapter; autocompletetextview view; button btn; arraylist<string>data; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); view=(autocompletetextview)findviewbyid(r.id.autocompletetextview1); btn=(button)findviewbyid(r.id.button1); data=new arraylist<string>(); for(int i=0;i<100;i++) { data.add("autocomplete"+i); } adapter = new arrayadapter (this,android.r.layout.simple_list_item_1,data); view.setadapter(adapter); btn.setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { // todo auto-generated method stub data.clear(); toast.maketext(getapplicationcontext(), "data size"+data.size(), toast.length_long).show(); for(int i=0;i<100;i++) { data.add("newdata"+i); } adapter.notifydatasetchanged(); toast.maketext(getapplicationcontext(), "data size= "+data.size(), toast.length_long).show(); } }); }
it not working. previous info showing. can now?
android autocomplete notifydatasetchanged
No comments:
Post a Comment