0

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.html Commented Mar 27, 2015 at 16:45
  • 1
    i have custom list view and numbers assigned to it, i just want to search for numbers that i assigned for Commented Mar 27, 2015 at 16:49

1 Answer 1

2

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;
            } });
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, its working but can you tell me how to search for number
Add to your list Adapter (Sample Adapter) ! mAdapter.getFilter().filter(query);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.