Santhosh_pulliman Santhosh_pulliman - 3 months ago 15
Android Question

Implementing Text Watcher for EditText

I have an EditText. When i click on it, it becomes focusable. I will type the input text to be entered into the EditText. I want to implement a listener for EditText, so that when i stop typing, it should automatically save that text into the database instead of having a button. How to have a listener for EditText to listen that typing is stopped or not?


set edittext imeOption


By using something like this,

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_DONE) {
            // Specify your database function here.
            return true;
        return false;

Alternatively, you can use the OnEditorActionListener interface to avoid the anonymous inner class.