简体   繁体   中英

How to change actionbar menu button with click on tab

There is 2 tab in activity first is image and second is video i want when there is image tab the menu button will be image on actionbar and when click on video tab the button change into video button. i am new on android and no idea what to do.

You can override the onMenuCreated method and by managing the flag of which tab you're in, create a menu item accordingly. The menu item should be set to show as action button (so it will be visible in the action bar).

Another approach is to create a toolbar layout, add the two buttons and manage their visibility.

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