HOW TO USE “OK” KEY ON SOFTKEYBOARD (NUMBERPASSWORD KEYBOARD) INSTEAD OF CLICKING BUTTON?

Sanjay Sharma

Total Post:45

Points:315
Posted by  Sanjay Sharma
 1081  View(s)
Ratings:
Rate this:

I have an EditText which InputType is numberPassword, and a Button"ANYNAME". I'd like to use "OK" key on softkeyboard (numeric keyboard) instead of the Button"ANYNAME" to execute a giving function in my code.

How can I realize that?

  1. Andrew Watson

    Post:39

    Points:273
    Re: How to use “OK” key on softkeyboard (numberPassword keyboard) instead of clicking button?

    mEditText.setOnEditorActionListener(new TextView.OnEditorActionListener()
    {
            @Override
            public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
                // call some function
                return false;
            }
        });

    if you want to change "Done" button title, use:

    mEditText.setImeActionLabel("OK", KeyEvent.KEYCODE_ENTER);

      Modified On Apr-08-2018 11:56:21 PM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!