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

        }
}
Paresh Mayani

Lazy android developer, exploring the horizon of android development since 7 years, currently working as a Technical Lead - Android at Simform Solutions, India. Former Application Architect at KarConnect. He is the Head/Organizer of Google Developers Group (GDG), Ahmedabad

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