0

This is the menu item for search view widget

this is what I am getting in my emulator

reixa
  • 6,795
  • 6
  • 49
  • 67

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,523
  • 2
  • 26
  • 72
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,598
  • 2
  • 19
  • 34