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.amen.browser.ComboViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setResult(RESULT_CANCELED);//from  w ww. ja v a 2  s. c o m
    Bundle extras = getIntent().getExtras();
    Bundle args = extras.getBundle(EXTRA_COMBO_ARGS);
    String svStr = extras.getString(EXTRA_INITIAL_VIEW, null);
    ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks;
    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.tab_view);
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    if (BrowserActivity.isTablet(this)) {
        bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO);
        bar.setHomeButtonEnabled(true);
    } else {
        bar.setDisplayOptions(0);
    }

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    /* mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks),
        BrowserBookmarksPage.class, args);*/
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0));
    } else {
        switch (startingView) {
        case Bookmarks:
            mViewPager.setCurrentItem(0);
            break;
        case History:
            mViewPager.setCurrentItem(1);
            break;
        case Snapshots:
            mViewPager.setCurrentItem(2);
            break;
        }
    }
}

From source file:com.schedule.ScheduleActivity.java

/**
 * Sets up Action Bar (if present)./*from  w  w w. ja va 2s .co m*/
 * 
 * @param showTabs
 *            whether to show tabs (if false, will show list).
 * @param selTab
 *            the selected tab or list item.
 */
public void setUpActionBar(boolean showTabs, int selTab) {
    if (Build.VERSION.SDK_INT < 11) {
        // No action bar for you!
        // But do not despair. In this case the layout includes a bar across
        // the
        // top that looks and feels like an action bar, but is made up of
        // regular views.
        return;
    }

    android.app.ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);

    // Set up a CompatActionBarNavHandler to deliver us the Action Bar
    // nagivation events
    CompatActionBarNavHandler handler = new CompatActionBarNavHandler(this);
    if (showTabs) {
        actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_TABS);
        int i;
        for (i = 0; i < MENUS.length; i++) {
            actionBar.addTab(actionBar.newTab().setText(MENUS[i]).setTabListener(handler));
        }
        actionBar.setSelectedNavigationItem(selTab);
    } else {
        actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
        SpinnerAdapter adap = new ArrayAdapter<String>(this, R.layout.actionbar_list_item, MENUS);
        actionBar.setListNavigationCallbacks(adap, handler);
    }

    // Show logo instead of icon+title.
    actionBar.setDisplayUseLogoEnabled(true);
}

From source file:ca.cmput301f13t03.adventure_datetime.view.BrowseView.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewpager);/*  ww  w  . j a v  a 2 s .c  o m*/

    /* Set up View Pager */
    _adapter = new ViewPagerAdapter(getSupportFragmentManager());
    _viewPager = (ViewPager) findViewById(R.id.pager);
    _viewPager.setAdapter(_adapter);

    /* Set up Tabs */
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {
        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            _viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        }
    };

    actionBar.addTab(actionBar.newTab().setText("Saved").setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText("My Stories").setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText("Online").setTabListener(tabListener));

    /* Change tabs when View Pager swiped */
    _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getActionBar().setSelectedNavigationItem(position);
        }
    });

}

From source file:com.bionx.res.about.InformationCenter.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.information_center);

    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());
    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//from w ww.ja  va  2 s  .  c om
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.example.ll.llsdktest.MainActivity.java

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

    //configuring SDK
    Setting.configureLimelightSettings("https://staging-api.lvp.llnw.net/rest",
            "https://staging-wlp.lvp.llnw.net/license", "limelight");
    LoggerUtil.setLogLevelByString("Debug", this);
    Setting.SetAnalyticsEndPoint(//ww  w  .  j a  v a  2  s . c  o  m
            "https://staging-mcs.lvp.llnw.net/r/MetricsCollectionService/recordMetricsEvent");

    setContentView(R.layout.activity_main);

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

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOnPageChangeListener(this);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);
    actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(0)).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(1)).setTabListener(this));
}

From source file:com.example.llsdktest2.MainActivity.java

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

    //configuring SDK
    Setting.configureLimelightSettings("https://staging-api.lvp.llnw.net/rest",
            "https://staging-wlp.lvp.llnw.net/license", "limelight");
    LoggerUtil.setLogLevelByString("Debug", this);
    Setting.SetAnalyticsEndPoint(//from   w w w . j  a va 2 s  .com
            "https://staging-mcs.lvp.llnw.net/r/MetricsCollectionService/recordMetricsEvent");

    setContentView(R.layout.activity_main);

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

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOnPageChangeListener(this);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOffscreenPageLimit(2);

    actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(0)).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(1)).setTabListener(this));

}

From source file:org.dmfs.webcal.fragments.PagerFragment.java

/**
 * Configures the tabs on the action bar.
 *///w w w . ja va  2  s  .  co  m
private void setupActionBarTabs() {
    ActionBar actionBar = getActivity().getActionBar();

    int tabCount = actionBar.getTabCount();
    int pageCount = mAdapter.getCount();

    // replace titles and listeners of existing tabs
    int i = 0;
    for (; i < tabCount && i < pageCount; ++i) {
        final Tab tab = actionBar.getTabAt(i);
        tab.setText(mAdapter.getPageTitle(i));
        tab.setTabListener(this);
    }

    // add missing tabs
    for (; i < pageCount; ++i) {
        actionBar.addTab(actionBar.newTab().setText(mAdapter.getPageTitle(i)).setTabListener(this));
    }

    // remove remaining tabs
    for (; i < tabCount; --tabCount) {
        actionBar.removeTabAt(i);
    }

    if (pageCount > 1) {
        int selection = mSelectedTab;
        // changing the navigation mode might trigger a call to onTabSelected overriding mSelectedTab with a wrong value, so save it
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        mSelectedTab = selection;
        if (selection < pageCount) {
            mViewPager.setCurrentItem(selection, false);
        }
    } else {
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    }
}

From source file:com.prolificcoder.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from w w  w. j  ava2  s .  c  o  m*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:ca.cmput301f13t03.adventure_datetime.view.AuthorEdit.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.viewpager);/*from   w  w w .  jav  a 2 s  .  com*/

    /* Set up View Pager */
    _adapter = new ViewPagerAdapter(getSupportFragmentManager());
    _viewPager = (ViewPager) findViewById(R.id.pager);
    _viewPager.setAdapter(_adapter);

    /* Set up Tabs */
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {
        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
        }

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            _viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
        }
    };

    actionBar.addTab(actionBar.newTab().setText("Edit").setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText("Overview").setTabListener(tabListener));
    actionBar.addTab(actionBar.newTab().setText("Preview").setTabListener(tabListener));

    /* Change tabs when View Pager swiped */
    _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            getActionBar().setSelectedNavigationItem(position);
        }
    });

    // Select 'Overview' at start
    getActionBar().setSelectedNavigationItem(1);

}

From source file:ca.ramnansingh.randy.ibmwatsonspeechqa.AudioRecordTest.java

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

    // Strictmode needed to run the http/wss request for devices > Gingerbread
    if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD) {
        StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
        StrictMode.setThreadPolicy(policy);
    }/*from w  w w .  java 2s. c  o m*/

    //setContentView(R.layout.activity_main);
    setContentView(R.layout.activity_tab_text);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    tabSTT = actionBar.newTab().setText("Speech to Text");
    tabTTS = actionBar.newTab().setText("Text to Speech");

    tabSTT.setTabListener(new MyTabListener(fragmentTabSTT));
    tabTTS.setTabListener(new MyTabListener(fragmentTabTTS));

    actionBar.addTab(tabSTT);
    actionBar.addTab(tabTTS);

    //actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#B5C0D0")));
}