Christopher Francisco
Christopher Francisco

Reputation: 16278

ActionBar Tab with Home Icon

Basically I want this:

 __________________________________
|      |      |      |      |      |
| Home | Tab1 | Tab2 | Tab3 | Tab4 |
|______|______|______|______|______|
|                                  |
|               My App             |
|                                  |
|                                  |
|                                  |
...

The "Home" is not a section, its just the icon, so it can't be clicked. The rest of the tabs are functional.

The question is, how to position the Tab navigation buttons beside the icon?

EDIT: I'm using ActionBar, FragmentPageAdapter and Fragments

Upvotes: 0

Views: 431

Answers (1)

tyczj
tyczj

Reputation: 73966

all you need to do is set the navigation type of the actionbar

ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
actionBar.setDisplayShowTitleEnabled(false);

Tab tab = actionBar.newTab()
                   .setText(R.string.artist)
                   .setTabListener(new TabListener<ArtistFragment>(
                           this, "artist", ArtistFragment.class));
actionBar.addTab(tab);

tab = actionBar.newTab()
               .setText(R.string.album)
               .setTabListener(new TabListener<AlbumFragment>(
                       this, "album", AlbumFragment.class));
actionBar.addTab(tab);

which is right from the docs http://developer.android.com/guide/topics/ui/actionbar.html#Tabs

EDIT

As CommonsWare pointed out which I forgot to include is that the tabs only appear in the actionbar in landscape mode and if you have too many tabs to fit in the actionbar they get compressed to dropdown navigation

Upvotes: 2

Related Questions