Hi, I am trying to override the IME action to show the search on the virtual keyboard. My EditText is in a control that fits into the action.
Here is what I have:
<EditText android:id="@+id/txtSearch" android:textSize="18dp" android:textColor="@color/main_text_black" android:layout_width="247dp" android:layout_height="fill_parent" android:imeOptions="actionSearch" android:gravity="center_vertical" android:singleLine="true" android:background="@null" android:layout_alignParentLeft="true" android:layout_marginLeft="38px" />
In the code, I have this listener installed on EditText :
@Override public boolean onEditorAction(TextView view, int arg1, KeyEvent arg2) { if((arg1 == EditorInfo.IME_ACTION_SEARCH) { for(OnSearchListener listener : _listeners) { listener.OnSearch(view, getSearchString()); } } InputMethodManager imm = (InputMethodManager)_context.getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); return false; }
arg1 always returns as 0 when I press the enter key, which is "unrecognized". I also tried different keyboards like sendMessage and none of them work. What's happening?
Thank you in advance!
android
dropsOfJupiter
source share