Android 3.0 HoneyComb- Display ActionBar – 2

By -

If you don’t know about ActionBar then check and look into the solution given in my previous article: Android 3.0 HoneyComb- Display ActionBar – 1.

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().setIcon(R.drawable.icon1).setTabListener(this));
       bar.addTab(bar.newTab().setIcon(R.drawable.icon2).setTabListener(this));
       bar.addTab(bar.newTab().setIcon(R.drawable.icon3).setTabListener(this));
       bar.addTab(bar.newTab().setIcon(R.drawable.icon4).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

        }
}

CEO & Co-Founder at SolGuruz® | Organiser @ GDG Ahmedabad | Top 0.1% over StackOverflow | 15+ years experienced Tech Consultant | Helping startups with Custom Software Development

Loading Facebook Comments ...
Loading Disqus Comments ...