Android Question AppCompat toolbar menu - "menu_opened" event?

Misterbates

Active Member
Licensed User
I'm using the AppCompat library to replace the standard Action bar as described in https://www.b4x.com/android/forum/t...3-using-a-toolbar-as-actionbar.49053/#content.

It all works as documented and I can dynamically adjust the menu items as needed.

I was wondering if there was any way I could detect when the user touches the "more" icon to open the menu, as I'd like to cancel some other ongoing UI activity at that point, rather than at the point where the user chooses a menu item. Is there anything like a "menu_opened" event?

Thanks.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Change the menu Java code to:
B4X:
Private Sub Activity_MenuOpen
   Log("MenuOpen")
End Sub

#If Java

public boolean _onCreateOptionsMenu(android.view.Menu menu) {
  if (processBA.subExists("activity_createmenu")) {
  processBA.raiseEvent2(null, true, "activity_createmenu", false, new de.amberhome.objects.appcompat.ACMenuWrapper(menu));
  return true;
  }
  else
  return false;
}
  @Override
  public boolean onMenuOpened(int featureId, android.view.Menu menu) {
     if (menu != null) {
       processBA.raiseEvent(null, "activity_menuopen");
     }
  return super.onMenuOpened(featureId, menu);
  }
#End If
 
Upvote 0

scsjc

Well-Known Member
Licensed User
Longtime User


Hello, can't take even on close ???? i found something on internet, and i try to use but dont work
B4X:
@Override
public void onPanelClosed(int featureId, Menu menu) {
    ...
}

Thank !!!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…