Android ActionBar tabs set initially selected tab

后端 未结 6 1158
-上瘾入骨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:15

    Use the other addTab calls to override this behaviour. You'll need to add the tab you want to be selected first (in your case, the tab at position 2). Relevant Javadoc

    actionBar.addTab(tab2);
    actionBar.addTab(tab0, 0, false);
    actionBar.addTab(tab1, 1, false);
    

提交回复
热议问题