Android ActionBar tabs set initially selected tab

后端 未结 6 1164
-上瘾入骨i
-上瘾入骨i 2020-12-15 05:53

I have noticed that when using

actionBar.setSelectedNavigationItem(x)

in the onCreate() method of my Activity, the tab item at position 0

6条回答
  •  爱一瞬间的悲伤
    2020-12-15 06:04

    For any others looking to do this you can also set the tab to selected by setting the position and then set true or false to indicate which tab should be selected

    actionBar.addTab(tab1, 0, false);
    actionBar.addTab(tab2, 1, true);
    actionBar.addTab(tab3, 2, false);
    

    Here are the docs on this approach: http://developer.android.com/reference/android/app/ActionBar.html#addTab(android.app.ActionBar.Tab, int, boolean)

提交回复
热议问题