Listening to the menu open
I have RelativeLayout
. In this case, I am creating multiple views ToggleButton
. The user can turn these ToggleButtons on and off.
When the user opens the Activity OptionMenu
, I want all those ToggleButtons to stop being. To do this, I programmatically set ToggleButtons to OFF in code onPrepareOptionsMenu
.
I also have PopupMenu
one registered at Imagebutton
. I want also when users open PopupMenu
by clicking a button Imagebutton
, all ToggleButtons will be disabled. So, I am switching togglebuttons in the Imagebutton code setOnClickListener
.
My problem is that updates to the state of the Togglebuttons (to Off) are only shown after closing OptionsMenu
or PopupMenu
. Instead, I want all ToggleButtons to turn off as soon as the user opens the menu. I thought I needed to use some OnFocusChangeListener
for some views. I tried to use it on Activity layout but it doesn't work.
How can I get the result I want?
source to share