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.android.dialer.calllog.CallLogActivity.java

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

    setContentView(R.layout.call_log_activity);

    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayShowHomeEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);

    final Tab allTab = actionBar.newTab();
    final String allTitle = getString(R.string.call_log_all_title);
    allTab.setContentDescription(allTitle);
    allTab.setText(allTitle);/*  w ww.  j  a v  a  2  s.c  o  m*/
    allTab.setTabListener(mTabListener);
    actionBar.addTab(allTab);

    final Tab missedTab = actionBar.newTab();
    final String missedTitle = getString(R.string.call_log_missed_title);
    missedTab.setContentDescription(missedTitle);
    missedTab.setText(missedTitle);
    missedTab.setTabListener(mTabListener);
    actionBar.addTab(missedTab);

    mViewPager = (ViewPager) findViewById(R.id.call_log_pager);
    mViewPagerAdapter = new ViewPagerAdapter(getFragmentManager());
    mViewPager.setAdapter(mViewPagerAdapter);
    mViewPager.setOnPageChangeListener(mOnPageChangeListener);
    mViewPager.setOffscreenPageLimit(1);
}

From source file:org.aakashlabs.arthashastra.Novice_Activity.java

/** Called when the activity is first created. */
@Override/*from w w  w . j  a  v a 2  s .  c  om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_novice);

    //ActionBar gets initiated
    ActionBar actionbar = getActionBar();
    //Tell the ActionBar we want to use Tabs.
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //initiating both tabs and set text to it.
    ActionBar.Tab Part1NTab = actionbar.newTab().setText("Part 1");
    ActionBar.Tab Part2NTab = actionbar.newTab().setText("Part 2");
    ActionBar.Tab Part3NTab = actionbar.newTab().setText("Part 3");

    //create the two fragments we want to use for display content
    // these are two objects of the fragment classes (yet to be made)   
    Fragment Part1NFragment = new Part1N();
    Fragment Part2NFragment = new Part2N();
    Fragment Part3NFragment = new Part3N();

    //set the Tab listener. Now we can listen for clicks.
    Part1NTab.setTabListener(new MyTabsListener(Part1NFragment));
    Part2NTab.setTabListener(new MyTabsListener(Part2NFragment));
    Part3NTab.setTabListener(new MyTabsListener(Part3NFragment));

    //add the two tabs to the action bar
    actionbar.addTab(Part1NTab);
    actionbar.addTab(Part2NTab);
    actionbar.addTab(Part3NTab);

}

From source file:com.cyanogenmod.settings.device.DeviceSettings.java

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

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.viewPager);/*  ww  w . ja v  a  2 s.  c o  m*/
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.category_screen_title), ScreenFragmentActivity.class,
            null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.category_sensors_title), SensorsFragmentActivity.class,
            null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.category_haptic_title), HapticFragmentActivity.class,
            null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.category_storage_title), StorageFragmentActivity.class,
            null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.category_dock_title), DockFragmentActivity.class, null);

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

From source file:com.little.ibooks.file.FileExplorerTabActivity.java

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

    setContentView(R.layout.file_fragment_pager);
    mViewPager = (ViewPager) findViewById(R.id.pager);

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

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null);
    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(INSTANCESTATE_TAB, 0));
    }//from  w  w  w .  j  a  va2  s .c  o  m

    // ?"WIFI"
    Intent intent = getIntent();
    if (intent != null) {
        String fileMode = intent.getStringExtra("mode");
        if (fileMode != null && "wifi".equals(fileMode)) {
            mViewPager.setCurrentItem(1);
        }
    }

}

From source file:com.javierd.about.AboutActivity.java

/** Called when the activity is first created. */
@Override/*from  w w  w  .  jav  a2 s . c o m*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);

    setContentView(mViewPager);
    appContext = getApplicationContext();

    ActionBar actionbar = getActionBar();
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionbar.setDisplayShowHomeEnabled(false);
    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(actionbar.newTab().setText(R.string.about_tab_title), AboutFragment.class, null);
    mTabsAdapter.addTab(actionbar.newTab().setText(R.string.features_tab_title), FeaturesFragment.class, null);
    mTabsAdapter.addTab(actionbar.newTab().setText(R.string.dirt_tab_title), DirtFragment.class, null);
    mTabsAdapter.addTab(actionbar.newTab().setText(R.string.contributors_tab_title), ContributorsFragment.class,
            null);
    mTabsAdapter.addTab(actionbar.newTab().setText(R.string.social_tab_title), SocialFragment.class, null);

}

From source file:org.aakashlabs.arthashastra.Advanced_Activity.java

/** Called when the activity is first created. */
@Override/*  w  w w .ja  v a 2  s. c om*/
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_advanced);

    //ActionBar gets initiated
    ActionBar actionbar = getActionBar();
    //Tell the ActionBar we want to use Tabs.
    actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    //initiating both tabs and set text to it.
    ActionBar.Tab Part1ATab = actionbar.newTab().setText("Part 1");
    ActionBar.Tab Part2ATab = actionbar.newTab().setText("Part 2");
    //  ActionBar.Tab Part3ATab = actionbar.newTab().setText("Part 3");

    //create the two fragments we want to use for display content
    // these are two objects of the fragment classes (yet to be made)   
    Fragment Part1AFragment = new Part1A();
    Fragment Part2AFragment = new Part2A();
    // Fragment Part3AFragment=  new Part3A();

    //set the Tab listener. Now we can listen for clicks.
    Part1ATab.setTabListener(new MyTabsListener3(Part1AFragment));
    Part2ATab.setTabListener(new MyTabsListener3(Part2AFragment));
    //      Part3ATab.setTabListener(new MyTabsListener3(Part3AFragment));

    //add the two tabs to the action bar
    actionbar.addTab(Part1ATab);
    actionbar.addTab(Part2ATab);
    // actionbar.addTab(Part3ATab);

}

From source file:com.eu.lad.JamCamViewer.JamCamViewerMainActivity.java

/**
 * Called when the activity is first created.
 *//*  w  w  w.  j a  v  a 2s.  c  om*/
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    // Check that the activity is using the layout version with
    // the main_fragment_container FrameLayout
    if (findViewById(R.id.route_pager) != null) {

        // However, if we're being restored from a previous state,
        // then remove any saved support fragments to avoid overlapping
        // the Action bar.
        if (savedInstanceState != null) {
            return;
        }

        // Initialise the route inventory
        routeInventory = new LinkedList<Route>();
        seedBaseData();

        // Set-up the tabs in the Action Bar
        final ActionBar actionBar = getActionBar();
        // Specify that tabs should be displayed in the action bar.
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        // Add a tab for each route in the routeInventory
        for (Route r : routeInventory) {
            ActionBar.Tab routeTab = actionBar.newTab();
            routeTab.setText(r.getRouteLabel());
            routeTab.setTabListener(this.getTabListener());
            actionBar.addTab(routeTab);
        }
    }

}

From source file:id.ridon.fileexplorer.FileExplorerTabActivity.java

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

    setContentView(R.layout.fragment_pager);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGES);

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

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_category), FileCategoryActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null);
    bar.setSelectedNavigationItem(PreferenceManager.getDefaultSharedPreferences(this).getInt(INSTANCESTATE_TAB,
            Util.CATEGORY_TAB_INDEX));
}

From source file:com.lj.fileexplorer.FileExplorerTabActivity.java

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

    setContentView(R.layout.fragment_pager);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    //????//from  www .ja  v a 2  s. com
    mViewPager.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGES);

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

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_category), FileCategoryActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null);

    //
    bar.setSelectedNavigationItem(PreferenceManager.getDefaultSharedPreferences(this).getInt(INSTANCESTATE_TAB,
            Util.CATEGORY_TAB_INDEX));
}

From source file:com.vandalsoftware.filter.PhotoPagerActivity.java

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

    final ViewPager viewPager = new ViewPager(this);
    viewPager.setId(R.id.pager);/* w w  w. j  a  va 2 s . c  o m*/
    viewPager.setPageMargin((int) (getResources().getDisplayMetrics().density * 10));
    setContentView(viewPager);
    setTitle(R.string.app_name);

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

    final TabsAdapter tabsAdapter = new TabsAdapter(this, viewPager);
    Bundle bundle;

    bundle = Bundle.EMPTY;
    tabsAdapter.addTab(bar.newTab().setText(R.string.no_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_BW);
    tabsAdapter.addTab(bar.newTab().setText(R.string.bw_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_CHILL);
    tabsAdapter.addTab(bar.newTab().setText(R.string.chill_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_ROSE);
    tabsAdapter.addTab(bar.newTab().setText(R.string.rose_filter), PhotoFragment.class, bundle);

    bundle = new Bundle();
    bundle.putInt(PhotoFragment.ARG_FILTER, PhotoFragment.FILTER_INVERT);
    tabsAdapter.addTab(bar.newTab().setText(R.string.invert_filter), PhotoFragment.class, bundle);

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