Android cursoradapter filter listview -
i'm trying filter listview cursoradapter. i've tried far:
customadapter adapter; cursor cursor; etsearch.addtextchangedlistener(new textwatcher (){ public void aftertextchanged(editable arg0) { // todo auto-generated method stub } public void beforetextchanged(charsequence arg0, int arg1, int arg2, int arg3) { // todo auto-generated method stub } public void ontextchanged(charsequence cs, int arg1, int arg2, int arg3) { // todo auto-generated method stub adapter.getfilter().filter(cs.tostring()); } }); cursor = dbhelper.getalliteminventorylistings(); adapter = new customadapter(this, cursor); lv.setadapter(adapter); lv.settextfilterenabled(true); adapter.setfilterqueryprovider(new filterqueryprovider() { @override public cursor runquery(charsequence constraint) { string stritemcode = constraint.tostring(); return dbhelper.getalliteminventorylistings(stritemcode); } });
when tried not filter. seems wrong? appreciated. thank you.
try add adapter.notifydatasetchanged();
after adapter.getfilter().filter(cs.tostring());
Comments
Post a Comment