how to implement search box like Google apps do in action-bar or else is there any libs for that suggestions, in my app i have custom list view with numbers according to them, i just want to search those numbers that's it any help thanks
2
-
developer.android.com/training/search/index.htmlNSimon– NSimon2015-03-27 16:45:55 +00:00Commented Mar 27, 2015 at 16:45
-
1i have custom list view and numbers assigned to it, i just want to search for numbers that i assigned forHemanth S– Hemanth S2015-03-27 16:49:57 +00:00Commented Mar 27, 2015 at 16:49
Add a comment
|
1 Answer
Add Item menu Search !
<item
android:id="@+id/option_menu_search"
app:actionViewClass="android.support.v7.widget.SearchView"
android:icon="@drawable/ic_search_white_24dp"
android:orderInCategory="10"
app:showAsAction="ifRoom|collapseActionView"
android:title="@string/abc_searchview_description_search"
>
add in your onOptionsItemSelected
SearchView searchView = (SearchView) menu.findItem(R.id.option_menu_search).getActionView();
then
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return true;
} });
2 Comments
Hemanth S
thanks, its working but can you tell me how to search for number
Ussef Ben Amor
Add to your list Adapter (Sample Adapter) !
mAdapter.getFilter().filter(query);