Reputation: 483
for menu item I know I can use onOptionsSelected, but what function do I use if I want to know when the menu itself is clicked? (the 3 dots showed in the image below).
Upvotes: 0
Views: 218
Reputation: 12953
You don't have to set click listener
to menu. Just override
the following methods.
//Called on you open menu. or when you click on menu the three dots.
@Override
public boolean onMenuOpened(int featureId, Menu menu) {
Toast.makeText(this, "Open", Toast.LENGTH_SHORT).show();
return true;
}
You can also override this to detect close:
// Called when you close (ie. by clicking outside etc)
@Override
public void onPanelClosed(int featureId, Menu menu) {
Toast.makeText(this, "closed", Toast.LENGTH_SHORT).show();
}
Upvotes: 2