0

I added some code to oncreate options menu like this

 SearchManager searchManager =
           (SearchManager) getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView =
            (SearchView) menu.findItem(R.id.search).getActionView();
    searchView.setSearchableInfo(
            searchManager.getSearchableInfo(getComponentName()));

Also I created a xml file in xml directory and I did what is said in this.But I don't know how to pass search query and get the result. Executing this getting action bar disappeared.

Sarbbottam
  • 5,150
  • 3
  • 27
  • 39
Kiran Benny Joseph
  • 6,607
  • 4
  • 37
  • 56
  • The link you provided explains exactly how to do this. It's explained in the [Setting Up the Search Interface](http://developer.android.com/training/search/setup.html#create-sa) section. What is it you are not understanding about those instructions? – NoChinDeluxe Mar 04 '16 at 18:33
  • But the query I have entered does not come to `query` variable.. – Kiran Benny Joseph Mar 04 '16 at 18:38

2 Answers2

6

Furthermore if you want have some callback use the code below, on putting some query and fetch it.

searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {

            return false;
        }

        @Override
        public boolean onQueryTextChange(String s) {
            return false;
        }
    });
UMESH0492
  • 1,658
  • 18
  • 30
0

Android Search View Example in android Working Source Code

https://drive.google.com/open?id=0BzBKpZ4nzNzUajJhNEV2N25qWlU

Keshav Gera
  • 9,806
  • 1
  • 67
  • 48