My application runs on Android 2.2 and later. In it, I use ActionbarSherlock to allow the use of the action bar for devices up to 3.0. I used EditText in the action bar to allow the user to enter search text.
Using the emulator with Android 4.0 and 4.1 (I have not tried 3.x because it is not a tablet application), when EditText is selected, a soft keyboard appears as desired. But not so, using Android 2.2 or 2.3.3, it just does not appear.
The code for EditText is simple:
item.setActionView(R.layout.collapsible_edittext); etInput = (EditText) item.getActionView().findViewById(R.id.etInput); etInput.requestFocus();
Markup:
<?xml version="1.0" encoding="utf-8"?> <EditText xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/etInput" android:layout_width="fill_parent" android:layout_height="wrap_content" android:hint="@string/search_hint" android:lines="1" android:maxLines="1" android:inputType="textFilter|textNoSuggestions" android:imeOptions="actionSend"/>
Now I tried to specially show the soft keyboard with this fragment right after etInput.requestFocus(); but it didn’t matter:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE); imm.showSoftInput(etInput, InputMethodManager.SHOW_IMPLICIT);
I am trying to figure out if this is a problem with ActionbarSherlock or a more general problem with Android. I looked through a lot of articles on how to cause a soft keyboard to appear in Activity, but have not yet found a solution.
thanks
mraviator
source share