简体   繁体   中英

Android: How to add a click listener to menu icon(3 dots at the top)?

The onOptionsItemSelected(MenuItem item) method can be used to identify a click on each menu item. But i need to have a listener that can identify the click on the menu title (3 vertical dots at the top right of action bar). How could i implement one?

您可以在活动上覆盖onMenuOpenedjavadoc )。

When you choose basic activity , you get that 3 dot menu with it.

You don't have to add any click listener to that button it is created automatically. Try to run the app in emulator to see the results.

You can edit the default items of that menu from (res>menu>menu_main.xml)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM