Add focus change listener to EditText
Description
The following code shows how to Add focus change listener to EditText.
Example
//create an anonymous inner class to act as an onfocus listener
EditText txt1 = (EditText)findViewById(R.id.txt1);
txt1.setOnFocusChangeListener(new View.OnFocusChangeListener()
{/*from w w w . java2 s. c o m*/
@Override
public void onFocusChange(View v, boolean hasFocus) {
Toast.makeText (getBaseContext(),
((EditText) v).getId() + " has focus - " + hasFocus,
Toast.LENGTH_LONG).show();
}
);