How to use onBlur function on EditText in android?-ThrowExceptions

Exception or error:

I have a requirement function onBlur like javascript in android. When user exit from an EditText field after typing something in it, then i want to show a Toast. It seems very simple but i could not find it. Any help would highly be appreciated.

How to solve:

Try something like this:

mEditText.setOnFocusChangeListener(new OnFocusChangeListener() {
    public void onFocusChange(View v, boolean hasFocus) {
        if (!hasFocus)
            Toast.makeText(getApplicationContext(), "unfocus", 2000).show();

Leave a Reply

Your email address will not be published. Required fields are marked *