android - How to restrict the user inputs to the choices in autocomplete? -
i have created auto complete text-view picks data particular set of values. want user able select provided values , not able go ahead other choice.
i have been looking feasible answer since long didn't hands on any. in regard appreciated.
ps: please note have tried out obvious text change watcher methods etc , looking more worthwhile. thank you! :)
requested code : (the usual basic auto complete one)
autotext.setadapter(this, android.r.layout.simple_dropdown_item_1line,arr); autotext.setonitemclicklistener(new adapterview.onitemclicklistener() { public void onitemclick(adapterview<?> parent, view view, int position, long id) { tool = my_adapter.getitem(position).tostring(); } }); autotext.setonitemselectedlistener(this); public void onitemclick(adapterview<?> arg0, view arg1, int arg2, long arg3) { intent i=new intent(this,home.class); startactivity(i); } public void onnothingselected(adapterview<?> arg0) { } public void onitemselected(adapterview<?> arg0, view arg1, int arg2,long arg3) { intent i=new intent(.this,home.class); startactivity(i); } public void aftertextchanged(editable arg0) { } public void beforetextchanged(charsequence arg0, int arg1, int arg2, int arg3) { } public void ontextchanged(charsequence arg0, int arg1, int arg2, int arg3) { tool=null; // trying capture value of item selected in variable *tool*. }
use digits tag in autocomplete view in xml..., or use inputtype tag
Comments
Post a Comment