Skip to content Skip to sidebar Skip to footer

How To Make A Listener When A User Start Typing?

I am designing a chat application using android studio and fire-base and got stock on how to make a listener like if the user is typing on the edit-text field The value of the user

Solution 1:

Are you looking for onTextChanged(CharSequence s, int start, int before, int count)?

Quoting from the TextWatcher

This method is called to notify you that, within s, the count characters beginning at start have just replaced old text that had length before.

This event will fired one user entered something into EditText.

Solution 2:

You can add textwatcher like this:

your_edit_text_name.addTextChangedListener(new TextWatcher() {
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void afterTextChanged(Editable s) {

    }
});

And capture your typing event in onTextChanged method. Hope this helps

Post a Comment for "How To Make A Listener When A User Start Typing?"