I need to show to Toolbar
menu item when EditText
gains focus and hide it when EditText
lose focus.
I try to implement using setOnFocusChangeListener
on EditText
like below:
edittext.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
sendMenuItem.setVisible(true);
} else {
sendMenuItem.setVisible(false);
}
}
});
but menu item is show and hide continuously as onFocusChange()
is calling multiple times.
onFocusChange() is calling multiple times .
It is strange Logcat shows me following warning:
requestLayout() improperly called by android.support.v7.widget.ActionMenuView
is there any other way to achieve this?