Example usage for android.app ActionBar setDisplayOptions

List of usage examples for android.app ActionBar setDisplayOptions

Introduction

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

Prototype

public abstract void setDisplayOptions(@DisplayOptions int options, @DisplayOptions int mask);

Source Link

Document

Set selected display options.

Usage

From source file:pack_generic.Act_NSPS.java

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

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);//from  w  w  w.  j  a v a2s.com
    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("Frag_Page"), Frag_Page.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Frag_List_Contacts"), Frag_List_Contacts.class, null);
    mTabsAdapter.addTab(bar.newTab().setText("Frag_Tabs"), Frag_Tabs.class, null);

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

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);/*from ww  w  .ja  va  2s  . com*/
    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);/*from w w  w . j  a  v a  2  s .  c o 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.evervolv.toolbox2.Toolbox.java

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

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);//w w w  . jav a2s.  c o m
    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));
    }
}

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 a2s  .  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.michellgaby.advsettings.DeviceSettings.java

@TargetApi(11)
@Override//from ww w.j av  a 2  s  .co m
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.viewPager);
    setContentView(mViewPager);

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

    // Remove title and icon
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowTitleEnabled(false);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.general_settings_title), GeneralSettings.class, null);
    /**
     * mTabsAdapter.addTab(
     * bar.newTab().setText(R.string.category_mdnie_title),
     * mDNIeFragmentActivity.class, null); mTabsAdapter.addTab(
     * bar.newTab().setText(R.string.category_sensors_title),
     * SensorsFragmentActivity.class, null);
     */

    mTabsAdapter.addTab(bar.newTab().setText(R.string.system_settings_title), SystemSettings.class, null);

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

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

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_ACTION_BAR);

    setContentView(R.layout.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  ww .j  a v  a  2 s.  c  om*/
}

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);//from  w ww.  j  av a  2  s . co 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));
    }
}

From source file:com.yohpapa.overlaymusicplayer.activity.MainActivity.java

private void setupActionBar() {
    ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);

    int lastPosition = PrefUtils.getInt(this, R.string.pref_last_tab_position, 0);

    for (int i = 0; i < fragmentNames.length; i++) {

        ActionBar.Tab tab = bar.newTab();
        tab.setText(fragmentNames[i]);//from  w ww. j a va2s  .c  o  m
        tab.setTabListener(new ActionBar.TabListener() {
            @Override
            public void onTabUnselected(Tab tab, FragmentTransaction ft) {
                Log.d(TAG, "onTabUnselected");
            }

            @Override
            public void onTabSelected(Tab tab, FragmentTransaction ft) {
                ViewPager pager = (ViewPager) findViewById(R.id.fragment_pager);
                pager.setCurrentItem(tab.getPosition());
                PrefUtils.setInt(MainActivity.this, R.string.pref_last_tab_position, tab.getPosition());
            }

            @Override
            public void onTabReselected(Tab tab, FragmentTransaction ft) {
                Fragment fragment = fragments[tab.getPosition()];
                if (fragment instanceof CommonListFragment) {
                    ((CommonListFragment) fragment).onTapWhenSelected();
                }
            }
        });
        boolean isSelected = false;
        if (i == lastPosition) {
            isSelected = true;
        }
        bar.addTab(tab, isSelected);
    }
}

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));
    }//ww  w.  ja va2s . c  o  m

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

}