• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android: Listadapter along with getfilter() for dynamic search filter?

AKA001

Newbie
Feb 10, 2016
10
0
I am having a list adapter:


final Listadapter Adapter = new Listadapter(this,packageList1, packageManager);


When trying to create dynamic search filter for the list items, I am unable to use list adapter along with get filter function. please refer below:




final Listadapter Adapter = new Listadapter(this,packageList1, packageManager);

apps.setAdapter(Adapter);



//enables filtering for the contents of the given ListView



SearchView sv = (SearchView) findViewById(R.id.inputSearch);

sv.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

@override

public boolean onQueryTextSubmit(String text) {

return false;

}



@override

public boolean onQueryTextChange(String text) {



Adapter.getFilter().filter(text);

return false;

}

});


During further search, I have seen that getfilter() works with Array adapter.

Is there a way to use getfilter() functionality with ListAdapter?

OR Use listAdapter as Array adapter in anyway?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones