[英]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.活动中有 2 个选项卡,第一个是图像,第二个是我想要的视频,当有图像选项卡时,菜单按钮将是操作栏上的图像,当单击视频选项卡时,按钮变为视频按钮。 i am new on android and no idea what to do.
我是 android 新手,不知道该怎么做。
You can override the onMenuCreated method and by managing the flag of which tab you're in, create a menu item accordingly.您可以覆盖 onMenuCreated 方法,并通过管理您所在选项卡的标志,相应地创建一个菜单项。 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.另一种方法是创建工具栏布局,添加两个按钮并管理它们的可见性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.