Show soft keyboard when search bar is activated in SearchView

I see this question focusing on the EditText SearchView when I activate the search from the ActionBar. However, the keyboard does not appear when it is focused. Is this not so, since it is just a normal EditText? (Is this the usual EditText?) This behavior is observed on the Android SDK level 11. (Samsung Galax Tab 7.7 with Android Android.)

I have a workaround at the moment when it connects to the onOptionsItemSelected(MenuItem item) method of my activity, showing the keyboard.

  @Override public boolean onOptionsItemSelected(MenuItem item) { boolean menuSelectionHandeled = super.onOptionsItemSelected(item); // menu_search is the id of the menu item in the ActionBar if (item.getItemId() == R.id.menu_search) { mInputManager.showSoftInput(null, InputMethodManager.SHOW_IMPLICIT); } return menuSelectionHandeled; } 

Where mInputManager is an instance of InputMethodManager .

ActionBar is built using ActionBarSherlock, and since the target device is Android 3.x, can this be the cause of the symptoms? According to the ActionBarSherlock FAQ :

The action bar on Android 3.x (also known as Honeycomb) does not work to implement all the features in Android 4.x (Ice Cream Sandwich). To provide a complete action bar API on all platforms and to unify the style for all versions of Android. implementation is used.

+8
android actionbarsherlock searchview
source share
1 answer

This should work:

 SearchView searchView = new SearchView(getContext()); searchView.setInputType(InputType.TYPE_CLASS_TEXT); searchView.setBackgroundColor(Color.WHITE); 
0
source share

All Articles