Managing Ok SoftKeyboard Buttons

I set the Ok key on the soft keyboard of Android when I click on the edittext shown below:

<EditText android:id="@+id/rlMP3SeekContainer" android:layout_width="0dp" android:layout_height="40dp" android:layout_weight="1" android:background="@drawable/text_rougea" android:singleLine="true" android:imeOptions="actionDone" android:ems="10" android:hint="@string/hint_deezer_search" android:paddingLeft="@dimen/eight_dp" android:paddingRight="@dimen/eight_dp" android:textColor="@color/black" android:textColorHint="@color/gray_text" android:textSize="@dimen/twelve_sp" /> 

When the keyboard appears, I want the user to do something by pressing the ok button. but how can I override the ok button on the keyboard to do what I want.

+4
source share
1 answer

You need to implement OnEditorActionListener:

 yourEditText.setOnEditorActionListener( new EditText.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { /* your code here */ } } }); 
+14
source

Source: https://habr.com/ru/post/1489695/


All Articles