android - Searchview searches only whole words instead searching in content -
i have searchfield searches in arrayadapter
inputsearch.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence cs, int arg1, int arg2, int arg3) { zt.this.adapter.getfilter().filter(cs); } @override public void beforetextchanged(charsequence arg0, int arg1, int arg2, int arg3) { } @override public void aftertextchanged(editable arg0) { } });
it searches whole word. example:
baloon
seach bal
returns baloon
, searching oon
returns nothing. , he'll return baloon
in case.
thanks helping.
you can use filterqueryprovider , pass adapter.setfilterqueryprovider().
adapter.setfilterqueryprovider(new filterqueryprovider() { public cursor runquery(charsequence constraint) { string s = '%' + constraint.tostring() + '%'; return getcontentresolver().query(contactscontract.commondatakinds.phone.content_uri, new string[] {phone._id, phone.display_name, phone.number}, phone.display_name + ' ? or ' + phone.number + ' ?', new string[] { s, s }, null); } });
use adapter.
Comments
Post a Comment