Example usage for android.app ActionBar newTab

List of usage examples for android.app ActionBar newTab

Introduction

In this page you can find the example usage for android.app ActionBar newTab.

Prototype

@Deprecated
public abstract Tab newTab();

Source Link

Document

Create and return a new Tab .

Usage

From source file:com.example.android.supportv13.app.FragmentNestingPagerSupport.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);/*w  w w . jav a  2 s  .  co m*/
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Simple"), CountingFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("List"), FragmentPagerSupport.ArrayListFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Cursor"), CursorFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Tabs"), FragmentTabsFragment.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:com.example.android.supportv13.app.ActionBarTabsPager.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);//w  w  w . ja  va  2  s. co m
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText("Simple"), CountingFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("List"), FragmentPagerSupport.ArrayListFragment.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Cursor"), CursorFragment.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:com.plnyyanks.frcnotebook.activities.ViewTeam.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceHandler.getTheme());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_team);

    activity = this;

    ActionBar bar = getActionBar();
    bar.setTitle(teamNumber != -1 ? "Team " + teamNumber : "All Data");

    //tab for team overview
    ActionBar.Tab teamOverviewTab = bar.newTab();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    teamOverviewTab.setText("All Notes");
    teamOverviewTab.setTag("all");
    teamOverviewTab.setTabListener(this);
    bar.addTab(teamOverviewTab);/*ww w .  ja  v a 2s .  c om*/
    bar.setDisplayHomeAsUpEnabled(true);

    //add an actionbar tab for every event the team is competing at
    ArrayList<String> events;
    if (teamNumber == -1) {
        events = StartActivity.db.getAllEventKeys();
    } else {
        Team team = StartActivity.db.getTeam(teamKey);
        events = team.getTeamEvents();
    }
    for (String eventKey : events) {
        Log.d(Constants.LOG_TAG, "Making AB Tab for " + eventKey);
        Event event = StartActivity.db.getEvent(eventKey);
        if (event == null)
            continue;
        ActionBar.Tab eventTab = bar.newTab();
        eventTab.setTag(event.getEventKey());
        eventTab.setText(event.getShortName());
        eventTab.setTabListener(this);
        bar.addTab(eventTab);
    }

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM, 0));
    } else {
        bar.setSelectedNavigationItem(0);
    }

}

From source file:com.dirtyunicorns.hfm.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set up the ViewPager with the sections adapter.
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);//w  w  w. j  av  a  2 s.  c o m
    setContentView(mViewPager);
    ActionBar actionbar = getActionBar();
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionbar.setDisplayShowHomeEnabled(false);
    actionbar.setDisplayShowTitleEnabled(false);
    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(actionbar.newTab().setText(R.string.title_section1), mainFragment.class, null);
    //mTabsAdapter.addTab(actionbar.newTab().setText(R.string.title_section2),customFragment.class, null);

}

From source file:edu.csh.coursebrowser.SectionInfoActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_section_info);
    Bundle args = this.getIntent().getExtras();

    this.args = args.getString("args");
    this.setTitle(args.getString("title"));
    Log.v("Sections", args.getString("args"));

    // Set up the action bar to show tabs.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // For each of the sections in the app, add a tab to the action bar.

    actionBar.addTab(actionBar.newTab().setText("All").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Non-Full").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Full").setTabListener(this));

}

From source file:fm.krui.kruifm.DJInfoActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dj_info_container_layout);
    showLoadingScreen(true);/*from   www .  j  av  a 2  s. co m*/

    // Allow custom home button actions
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);

    /* For each component, create a tab for navigation */
    // Stream
    ActionBar.Tab bioTab = actionBar.newTab().setText(getResources().getString(R.string.dj_bio_tab))
            .setTabListener(this);
    // Extended Playlist
    ActionBar.Tab twitterTab = actionBar.newTab().setText(getResources().getString(R.string.dj_twitter_tab))
            .setTabListener(this);

    // Then apply the tabs to the ActionBar.
    actionBar.addTab(bioTab);
    actionBar.addTab(twitterTab);

    // Download DJ object attached to the last played song to display information.
    Log.v(TAG, "Grabbing DJ information...");
    DJInfoFetcher fetcher = new DJInfoFetcher(this, this);
    fetcher.execute();
}

From source file:in.ac.iitb.intulearn.DetailsActivity.java

/**
 * Initialise the fragments to be paged//from   w w w  .ja  va 2 s .co  m
 */
private void initialisePaging() {

    // Set up the action bar.
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    // Show the Up button in the action bar.
    actionBar.setDisplayHomeAsUpEnabled(true);

    // REF: http://android-er.blogspot.in/2012/06/create-actionbar-in-tab-navigation-mode.html
    actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_description)
            .setTabListener(new CustomTabListener(this, DescriptionFragment.class.getName())));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_experiment)
            .setTabListener(new CustomTabListener(this, ExperimentFragment.class.getName())));
    actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_evaluate)
            .setTabListener(new CustomTabListener(this, EvaluateFragment.class.getName())));

}

From source file:com.android.photos.GalleryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mMultiChoiceManager = new MultiChoiceManager(this);
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.viewpager);/*  w  ww.jav  a  2 s .  c om*/
    setContentView(mViewPager);

    ActionBar ab = getActionBar();
    ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ab.setDisplayShowHomeEnabled(false);
    ab.setDisplayShowTitleEnabled(false);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(ab.newTab().setText(R.string.tab_photos), PhotoSetFragment.class, null);
    mTabsAdapter.addTab(ab.newTab().setText(R.string.tab_albums), AlbumSetFragment.class, null);

    if (savedInstanceState != null) {
        ab.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:com.digi.android.sample.xbeemanager.XBeeTabsActivity.java

/**
 * Configures the activity tabs of the action bar.
 *//*from   w  ww .j  av  a 2 s  .  c o m*/
private void configureTabs() {
    ActionBar actionBar = getActionBar();
    if (actionBar == null)
        return;

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    XBeeDeviceTabListener xbeeDeviceTabListener = new XBeeDeviceTabListener();

    Tab infoTab = actionBar.newTab();
    infoTab.setText(getResources().getString(R.string.device_info_fragment_title));
    infoTab.setTabListener(xbeeDeviceTabListener);

    Tab discoverTab;
    discoverTab = actionBar.newTab();
    discoverTab.setText(getResources().getString(R.string.device_discovery_fragment_title));
    discoverTab.setTabListener(xbeeDeviceTabListener);

    Tab framesTab = actionBar.newTab();
    framesTab.setText(getResources().getString(R.string.frames_fragment_title));
    framesTab.setTabListener(xbeeDeviceTabListener);

    actionBar.addTab(infoTab);
    actionBar.addTab(discoverTab);
    actionBar.addTab(framesTab);
}

From source file:com.evervolv.toolbox2.Toolbox.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);/*from   w  ww  . j  a  v  a2 s . c om*/
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setDisplayHomeAsUpEnabled(true);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.interface_title), Interface.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.performance_title), Performance.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.updates_title), Updates.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}