I have a fragment that contains EditText and I am trying to setup keyboard event but it doesn't seem to work. The actionId
is always 0
.
<android.support.v7.widget.AppCompatEditText
android:id="@+id/input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/hint_name"
android:inputType="text"
android:maxLines="1"
android:imeOptions="actionNext"
android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"/>
name.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_NEXT) {
save();
handled = true;
}
return handled;
}
});
I have also tried to set button label using following code but it does not work
name.setImeActionLabel("Next", KeyEvent.KEYCODE_ENTER);