简体   繁体   English

单击按钮以切换到Android操作栏中的其他选项卡

[英]Click button to switch to other tab in actionbar in Android

I am using Action Bar by set code as bellow: 我通过将代码设置为波纹管来使用操作栏:

actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

I want to use a button in First Tab, when click, change to Second Tab by using: 我想在“第一标签”中使用一个按钮,单击后,通过使用以下命令更改为“第二标签”:

setSelectedNavigationItem(1);

Tab change but tab indicator still select on First Tab. 选项卡更改,但选项卡指示器仍在“第一个选项卡”上选择。

Please Help, Thank in advance. 请帮助,在此先感谢。

Try this - 尝试这个 -

actionBar.setSelectedNavigationItem(1);
//it will switch the tab

viewPager.setCurrentItem(1);
//it will set the indicator

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过按钮从一个选项卡视图移动到另一个视图单击Android ActionBar - Moving From one tab view to another by button Click Android ActionBar 如何单击片段中的按钮以切换到Kotlin中的其他选项卡? - How to click a button in a fragment to switch to other Tab in Kotlin? Android - 将 ActionBar 后退按钮切换为导航按钮 - Android - Switch ActionBar Back Button to Navigation Button 如何通过单击选项卡更改操作栏菜单按钮 - How to change actionbar menu button with click on tab Android- 在选项卡之间切换后退按钮(选项卡导航操作栏)? - Android- Make back button switch between tabs (tab navigation actionbar)? 单击“ ActionBar”选项卡上的“更改”图标或滑动-Android - Change icon on ActionBar tab click or swipe - Android Android操作栏:以编程方式单击向上按钮 - Android Actionbar: click Up-Button programmatically android-actionbar更改单击主页按钮 - android-actionbar change home button on click 从向上箭头切换到按钮上的汉堡包图标单击操作栏中的 - Switch from Up Arrow to Hamburger Icon on Button Click in ActionBar 在ActionBar $ Tab上单击操作 - Click action on ActionBar$Tab
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM