Reputation: 346
Here my code:
Tab tab = actionBar
.newTab()
.setText(R.string.friends)
.setTabListener(
new TabListener<FriendsFragment>(this, "friends_list",
FriendsFragment.class));
actionBar.addTab(tab);
tab = actionBar
.newTab()
.setText(R.string.home)
.setTabListener(
new TabListener<UserHomeFragment>(this, "user_home",
UserHomeFragment.class));
actionBar.addTab(tab);
tab = actionBar
.newTab()
.setText(R.string.highscores)
.setTabListener(
new TabListener<HighscoresFragment>(this, "highscores",
HighscoresFragment.class));
actionBar.addTab(tab);
How can i set the "UserHome" as first tab displayed/selected? I want it in the middle like now. So when my "TabActivity" start it will be like this: Friends - Home - Highscores
Upvotes: 1
Views: 6419
Reputation: 6380
There are a few options, the easiest with your current implementation be to just set it as the selected tab when adding the tab to the action bar with ActionBar#addTab(Tab tab, boolean setSelected).
Alternatively you could set the selection with ActionBar#setSelectedNavigationItem(int position).
Upvotes: 5