You can get the element by getting the view id, using the getId()
method, for example
public void onFocusChange(View v, boolean hasFocus) {
switch (v.getId()) {
case R.id.editText1:
//caso for o editText1
break;
case R.id.editText2:
//caso for o editText2
break;
}
}
Create%, separated, not already as edittext parameter, for example:
View.OnFocusChangeListener exemplo = new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
switch (v.getId()) {
case R.id.editText1:
//caso for o editText1
break;
case R.id.editText2:
//caso for o editText2
break;
}
}
} ;
and then only assign to edittext
editText1.setOnFocusChangeListener(exemplo);
editText2.setOnFocusChangeListener(exemplo);