Back to project page Implementing-ActionBarSherlock-Fragment-Tabs-in-Android.
The source code is released under:
Apache License
If you think the Android project Implementing-ActionBarSherlock-Fragment-Tabs-in-Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.sherlockfragmenttabs; /* w ww . j a va 2 s .c o m*/ import com.actionbarsherlock.app.ActionBar; import com.actionbarsherlock.app.SherlockFragmentActivity; import com.actionbarsherlock.app.ActionBar.Tab; import android.os.Bundle; public class MainActivity extends SherlockFragmentActivity { // Declare Tab Variable Tab tab; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Create the Actionbar ActionBar actionBar = getSupportActionBar(); // Hide Actionbar Icon actionBar.setDisplayShowHomeEnabled(false); // Hide Actionbar Title actionBar.setDisplayShowTitleEnabled(false); // Create Actionbar Tabs actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create first Tab tab = actionBar.newTab().setTabListener(new FragmentsTab1()); // Create your own custom icon tab.setIcon(R.drawable.tab1); actionBar.addTab(tab); // Create Second Tab tab = actionBar.newTab().setTabListener(new FragmentsTab2()); // Set Tab Title tab.setText("Tab2"); actionBar.addTab(tab); // Create Third Tab tab = actionBar.newTab().setTabListener(new FragmentsTab3()); // Set Tab Title tab.setText("Tab3"); actionBar.addTab(tab); } }