Android 3.0 Honeycomb - Display Action bar using textual tab

1 vote · 1 comment

Here you can find more information regarding the same article at: http://goo.gl/KKlhD

I have tested it on the Honeycomb android emulator and its working fine.

raw ·
copy
· download
public class actionBarTest extends Activity implements ActionBar.TabListener{ /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ActionBar bar = getActionBar(); bar.addTab(bar.newTab().setText("Tab 1").setTabListener(this)); bar.addTab(bar.newTab().setText("Tab 2").setTabListener(this)); bar.addTab(bar.newTab().setText("Tab 3").setTabListener(this)); bar.addTab(bar.newTab().setText("Tab 4").setTabListener(this)); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayShowHomeEnabled(true); // remove the activity title to make space for tabs bar.setDisplayShowTitleEnabled(false); } @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { // TODO Auto-generated method stub } }
Add a comment

1 Comment

Another simple tutorial showing Action bar Tabs with native language support. Click the link below.

http://android-helper4u.blogspot.com/2013/02/c-how-to-create-tabs-using-action-bar.html

Reply · Feb. 22, 2013, 6:54 p.m.