简体   繁体   中英

Is it possible to implement Tab Host on action-bar in android?

I have implemented tab host with navigation drawer using ActionBarShaerlock. Currently element to open navigation drawer on action bar and tab host in bottom of it.

屏幕截图

I want tabs in actionbar. It it possible to do so?

you can add tabs below action bar using something like this-

  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);

see this link here

hope this will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM