android studio - search in listview of objects with customAdapter extends ArrayAdapter -


i have customadapter listview,i'm trying search shows if have nothing matches string type.

this customadapter`public class customadapter extends arrayadapter implements filterable {

public customadapter(context context, int resource, list<office> offices) {     super(context, resource, offices); }  @override public view getview(int position, view convertview, viewgroup parent) {      view v = convertview;      if (v == null) {         layoutinflater inflater = (layoutinflater) getcontext().getsystemservice(context.layout_inflater_service);         v = inflater.inflate(r.layout.view_entry, parent, false);     }      office office = getitem(position);      if (office != null) {         textview tvpersonid = (textview) v.findviewbyid(r.id.section_id);         textview tvpersonname = (textview) v.findviewbyid(r.id.section_name);          tvpersonname.settext(office.officename);         tvpersonid.settext( integer.tostring(office.officeid));      }      return v; } 

this in activity

lv.setadapter(customadapter);                          searchbox.addtextchangedlistener(new textwatcher() {                              @override                              public void ontextchanged(charsequence cs, int arg1, int arg2, int arg3) {                                  customadapter.getfilter().filter(cs);                              }                              @override                              public void beforetextchanged(charsequence arg0, int arg1, int arg2,int arg3) {                              }                              @override                              public void aftertextchanged(editable arg0) {                              }                           }); 

i have edittext every time type sonething clears out listview please help!!


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -