I have an activity with 2 types of views EditText
and CustomEditText
my custom edit text has a onFocusChanged()
method and I can know when the view gains and looses focus, but I would like to know which view gains focus in order to perform different actions, is possible to know from the onFocusChanged()
method which view got focus after this view looses it?
Calling getCurrentFocus()
from the overwritten method in a custom view like this will return null so that will not work
@Override
protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
if (focused ) {
}else{
Activity activity = (Activity) this.getContext();
activity.getCurrentFocus();//this returns null
}
super.onFocusChanged(focused, direction, previouslyFocusedRect);
}