does anyone know what keycode I have to press for this Send/Search/Next button? I'm trying to send a chat message and can't find a solution to this one. Already tried keycode: 66 and 84.
For adding action on click of send/done button of soft keyboard, Need to add setOnEditorActionListener
to edittext.
EditText
code in xml :
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionSend"
android:singleLine="true"/>
In Java class:
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEND) {
String text = editText.getText().toString();
Log.e(TAG,"text-----"+text);
return true;
}
return false;
}
});
You can add any imeOptions
to edittext according to your requirement.
For more info related to EditerInfo check official doc.