List of usage examples for android.support.v4.app ActionBar newTab
public abstract ActionBar.Tab newTab();
From source file:com.actionbarsherlock.sample.hcgallery.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null && savedInstanceState.getInt("theme", -1) != -1) { mThemeId = savedInstanceState.getInt("theme"); this.setTheme(mThemeId); }/*from w w w . j a v a 2s . c om*/ setContentView(R.layout.main); Directory.initializeDirectory(); ActionBar bar = getSupportActionBar(); int i; for (i = 0; i < Directory.getCategoryCount(); i++) { bar.addTab(bar.newTab().setText(Directory.getCategory(i).getName()).setTabListener(this)); } mActionBarView = getLayoutInflater().inflate(R.layout.action_bar_custom, null); bar.setCustomView(mActionBarView); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayShowHomeEnabled(true); // If category is not saved to the savedInstanceState, // 0 is returned by default. if (savedInstanceState != null) { int category = savedInstanceState.getInt("category"); bar.selectTab(bar.getTabAt(category)); } }
From source file:com.abcvoipsip.ui.prefs.Codecs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.codecs_pager); final ActionBar ab = getSupportActionBar(); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ab.setDisplayShowHomeEnabled(true);/*from w w w . j ava2 s . com*/ ab.setDisplayShowTitleEnabled(true); mViewPager = (ViewPager) findViewById(R.id.pager); TabsAdapter tabAdapter = new TabsAdapter(this, ab, mViewPager); Tab audioNb = ab.newTab().setText(R.string.narrow_band).setIcon(R.drawable.ic_prefs_media); Tab audioWb = ab.newTab().setText(R.string.wide_band).setIcon(R.drawable.ic_prefs_media); Tab videoNb = ab.newTab().setText(R.string.narrow_band).setIcon(R.drawable.ic_prefs_media_video); Tab videoWb = ab.newTab().setText(R.string.wide_band).setIcon(R.drawable.ic_prefs_media_video); tabAdapter.addTab(audioWb, CodecsFragment.class); tabAdapter.addTab(audioNb, CodecsFragment.class); tabAdapter.addTab(videoWb, CodecsFragment.class); tabAdapter.addTab(videoNb, CodecsFragment.class); }
From source file:com.actionbarsherlock.sample.styledactionbar.MainActivity.java
/** Called when the activity is first created. */ @Override/*from w w w .ja v a2 s . com*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ActionBar ab = getSupportActionBar(); // set defaults for logo & home up ab.setDisplayHomeAsUpEnabled(showHomeUp); ab.setDisplayUseLogoEnabled(useLogo); // set up tabs nav for (int i = 1; i < 4; i++) { ab.addTab(ab.newTab().setText("Tab " + i).setTabListener(this)); } // set up list nav ab.setListNavigationCallbacks(ArrayAdapter.createFromResource(this, R.array.sections, android.R.layout.simple_spinner_dropdown_item), new OnNavigationListener() { public boolean onNavigationItemSelected(int itemPosition, long itemId) { // FIXME add proper implementation rotateLeftFrag(); return false; } }); // default to tab navigation showTabsNav(); // create a couple of simple fragments as placeholders final int MARGIN = 16; leftFrag = new RoundedColourFragment(getResources().getColor(R.color.android_green), 1f, MARGIN, MARGIN / 2, MARGIN, MARGIN); rightFrag = new RoundedColourFragment(getResources().getColor(R.color.honeycombish_blue), 2f, MARGIN / 2, MARGIN, MARGIN, MARGIN); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.root, leftFrag); ft.add(R.id.root, rightFrag); ft.commit(); }
From source file:com.abcvoipsip.ui.SipHome.java
@Override protected void onCreate(Bundle savedInstanceState) { //prefWrapper = new PreferencesWrapper(this); prefProviderWrapper = new PreferencesProviderWrapper(this); /*//from w w w.j a v a 2 s. c o m * Resources r; try { r = * getPackageManager().getResourcesForApplication("com.etatgere"); int * rThemeId = r.getIdentifier("com.etatgere:style/LightTheme", null, * null); Log.e(THIS_FILE, "Remote theme " + rThemeId); Theme t = * r.newTheme(); t.applyStyle(rThemeId, false); //getTheme().setTo(t); } * catch (NameNotFoundException e) { Log.e(THIS_FILE, * "Not found app etatgere"); } */ if (USE_LIGHT_THEME) { setTheme(R.style.LightTheme_noTopActionBar); } super.onCreate(savedInstanceState); setContentView(R.layout.sip_home); final ActionBar ab = getSupportActionBar(); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); // showAbTitle = Compatibility.hasPermanentMenuKey ab.setDisplayShowHomeEnabled(false); ab.setDisplayShowTitleEnabled(false); Tab dialerTab = ab.newTab() // .setText(R.string.dial_tab_name_text) .setIcon(R.drawable.ic_ab_dialer_holo_dark); Tab callLogTab = ab.newTab() // .setText(R.string.calllog_tab_name_text) .setIcon(R.drawable.ic_ab_history_holo_dark); Tab favoritesTab = ab.newTab() // .setText(R.string.messages_tab_name_text) .setIcon(R.drawable.ic_ab_favourites_holo_dark); Tab messagingTab = null; if (CustomDistribution.supportMessaging()) { messagingTab = ab.newTab() // .setText(R.string.messages_tab_name_text) .setIcon(R.drawable.ic_ab_text_holo_dark); } mDualPane = getResources().getBoolean(R.bool.use_dual_panes); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, getSupportActionBar(), mViewPager); mTabsAdapter.addTab(dialerTab, DialerFragment.class); mTabsAdapter.addTab(callLogTab, CallLogListFragment.class); mTabsAdapter.addTab(favoritesTab, FavListFragment.class); if (messagingTab != null) { mTabsAdapter.addTab(messagingTab, ConversationsListFragment.class); } hasTriedOnceActivateAcc = false; if (!prefProviderWrapper.getPreferenceBooleanValue(SipConfigManager.PREVENT_SCREEN_ROTATION)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } selectTabWithAction(getIntent()); Log.setLogLevel(prefProviderWrapper.getLogLevel()); // Async check asyncSanityCheker = new Thread() { public void run() { asyncSanityCheck(); }; }; asyncSanityCheker.start(); }