My app works on Android 2.2 and later. In it, I use ActionbarSherlock to allow the action bar usage for pre-3.0 devices. I used an EditText in the action bar to allow user text input for search.
Using the emulator, with Android 4.0 and 4.1 (I have not tried 3.x because it's not a tablet app), when the EditText is selected, the soft keyboard pops up as desired. But not so using Android 2.2 or 2.3.3, it just does not display.
The code for the EditText is straightforward:
item.setActionView(R.layout.collapsible_edittext);
etInput = (EditText) item.getActionView().findViewById(R.id.etInput);
etInput.requestFocus();
Layout:
<?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've tried specifically showing the soft keyboard using this snippet immediately after etInput.requestFocus();
, but it made no difference:
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(etInput, InputMethodManager.SHOW_IMPLICIT);
I'm trying to figure out if this is an issue with ActionbarSherlock or a more general Android issue. I've scoured the many articles on forcing soft keyboard display in an Activity, but have not yet found the solution.
Thanks