2

I am using this code in XML file for edit text.

<EditText
            android:id="@+id/et_login_password"
            android:layout_width="match_parent"
            android:layout_height="@dimen/fragment_login_views_height"
            android:layout_below="@+id/et_login_email"
            android:ems="10"
            android:hint="password"
            android:inputType="textPassword"
            android:text="Vidcode2015"
            android:textColor="@color/primary_dark"
            android:textColorHint="@android:color/tertiary_text_light"
            android:textSize="@dimen/fragment_login_views_text_size" />

And in java file i am setting edittext properties.

et_password.setImeActionLabel("Login",EditorInfo.IME_ACTION_SEND );
        et_password.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                boolean handled = false;
                if (actionId == EditorInfo.IME_ACTION_SEND) {
                    performLogin(et_user.getText().toString(), et_password.getText().toString());
                    handled = true;
                }
                return handled;
            }
        });
Amna Mirza
  • 705
  • 1
  • 5
  • 21

1 Answers1

0

Android only provide with specific labels through imeOptions on edit text to set on softkeyboard button, like done or send e.t.c. User cannot set his/her own label like login or abc e.t.c

Amna Mirza
  • 705
  • 1
  • 5
  • 21
  • 2
    That's not true. setImeActionLabel("Login",EditorInfo.IME_ACTION_SEND ) works in 'Ice Cream Sandwich', but not on 'Lollipop' – Ketobomb Jul 13 '17 at 07:56
  • Testing on Android 7/10 using emulator, the text of the keyboard's enter button can be changed but using Android 10 on a real device, no matter the keyboard - Samsung's one, Microsoft's SwiftKey or Google's Gboard, either the default text for the button is shown - Samsung's keyboard, or an icon - SwiftKey and Gboard. Moreover, using the keyboards on a physical device it is possible to dynamically change the button's type using InputMethodMenager.RestartInput. To do this in an emulator, probably one would need to reopen the keyboard as well. – Ivan Caravanio Sep 15 '20 at 15:08