0

This is the menu item for search view widget

this is what I am getting in my emulator

reixa
  • 6,903
  • 6
  • 49
  • 68

2 Answers2

0

Activity file: For the more detail please read this answer .

 public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.menu.dashboard, menu);

         MenuItem searchItem = menu.findItem(R.id.action_search);

        SearchManager searchManager = (SearchManager) MainActivity.this.getSystemService(Context.SEARCH_SERVICE);

        SearchView searchView = null;
        if (searchItem != null) {
            searchView = (SearchView) searchItem.getActionView();
        }
        if (searchView != null) {
            searchView.setSearchableInfo(searchManager.getSearchableInfo(MainActivity.this.getComponentName()));
        }
            return super.onCreateOptionsMenu(menu);
    }
Community
  • 1
  • 1
Muhammad Waleed
  • 2,517
  • 4
  • 27
  • 75
0

Set searchView.setIconified(false); This will show EditText on opening the screen with searchView.

You can see here for the details: Show android SearchView EditText by default

Community
  • 1
  • 1
Android Geek
  • 8,956
  • 2
  • 21
  • 35