xknozi
xknozi

Reputation: 1485

KeyEvent in android

I want to know how to use the onKeyDown event in android.

Because I want to make an app, that Whenever I type in anything in an editText, the Textview will automatically update and display the text i inputted.

Upvotes: 1

Views: 375

Answers (2)

Boe-Dev
Boe-Dev

Reputation: 1595

this is the method

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        //Your stuff
        return super.onKeyDown(keyCode, event);
    }   

you can check there for the keyCode or the KeyEvent.

In a project I developed before, I use a runnable method to check the Edittext.

Upvotes: 0

Lalit Poptani
Lalit Poptani

Reputation: 67286

I would insist that in your case the better option is to use TextWatcher for EditText. You can just set the listener for EditText using addTextChangedListener() and append the text from EditText to TextView. Here is how you can use TextWatcher for EditText.

Upvotes: 1

Related Questions