Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use onBlur function on EditText in android?

Tags:

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.

like image 866
Rafiqul Islam Avatar asked Nov 30 '11 06:11

Rafiqul Islam


1 Answers

Try something like this:

mEditText.setOnFocusChangeListener(new OnFocusChangeListener() {     @Override     public void onFocusChange(View v, boolean hasFocus) {         if (!hasFocus)             Toast.makeText(getApplicationContext(), "unfocus", 2000).show();     } }); 
like image 84
Vladimir Avatar answered Oct 09 '22 20:10

Vladimir