Example usage for android.app ActionBar setNavigationMode

List of usage examples for android.app ActionBar setNavigationMode

Introduction

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

Prototype

@Deprecated
public abstract void setNavigationMode(@NavigationMode int mode);

Source Link

Document

Set the current navigation mode.

Usage

From source file:com.herasymc.cmput301counter.CounterSummaryActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_counter_summary);

    list = CounterList.getInstance(getApplicationContext());
    id = (int) getIntent().getLongExtra("id", -1); // if id is -1, summarize all counters

    // Set up the action bar to show a dropdown list.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    // Show the Up button in the action bar.
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Set up the dropdown list navigation in the action bar.
    actionBar.setListNavigationCallbacks(
            // Specify a SpinnerAdapter to populate the dropdown list.
            new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1,
                    android.R.id.text1,/*from w  ww .jav a  2s  . c o  m*/
                    new String[] { getString(R.string.title_summary_minute),
                            getString(R.string.title_summary_hour), getString(R.string.title_summary_day),
                            getString(R.string.title_summary_week), getString(R.string.title_summary_month) }),
            this);
}

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  w w w  . j  a  v a 2  s.  co m
    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: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:org.messic.android.activities.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);

    // 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(getFragmentManager());

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

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override// w w w. j a  v  a  2s . co  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 < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:ca.psiphon.ploggy.ActivityMain.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Create the adapter that will return a fragment for each of the three primary sections
    // of the app.
    mAppTabsPagerAdapter = new AppTabsPagerAdapter(getSupportFragmentManager());

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

    // Specify that the Home/Up button should not be enabled, since there is
    // no hierarchical parent.
    actionBar.setHomeButtonEnabled(false);

    // Set up the ViewPager, attaching the adapter and setting up a listener for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppTabsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override//from   www.  j  a  v  a2  s.co m
        public void onPageSelected(int position) {
            // When swiping between different app sections, select the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    actionBar.addTab(actionBar.newTab().setText(R.string.title_self_status_fragment).setTabListener(this));

    actionBar.addTab(actionBar.newTab().setText(R.string.title_friend_list_fragment).setTabListener(this));

    actionBar.addTab(actionBar.newTab().setText(R.string.title_message_list_fragment).setTabListener(this));
    mMessageListTabIndex = 2;

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

From source file:de.toshsoft.tsremote.configuration.ConfigurationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // Remove all StandOut Windows
    StandOutWindow.closeAll(this, StandOutRemoteActivity.class);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.configuration_activity);

    // 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 app.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from w ww  .ja v  a 2 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 < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:org.monospace.smsfilter.MainActivity.java

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

    mTabs = new TabSet(NUM_TABS);
    mTabs.add(TAB_SMS, R.string.tab_sms_list, SMSListFragment.class);
    mTabs.add(TAB_FILTER, R.string.tab_filter_list, FilterListFragment.class);

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

    ViewPager pager = new ViewPager(this);
    pager.setId(R.id.main_pager);/*from ww  w.  j av  a 2s .  c  o  m*/

    TabHelper helper = new TabHelper(this, pager);
    pager.setAdapter(helper);
    pager.setOnPageChangeListener(helper);

    for (TabSet.Tab t : mTabs) {
        Tab tab = actionBar.newTab().setText(t.textId).setTabListener(helper);
        actionBar.addTab(tab);
    }

    setContentView(pager);

    mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            SMSListFragment fragment = (SMSListFragment) mTabs.getItem(TAB_SMS);
            fragment.refresh();
        }
    };

    registerReceiver(mReceiver, new IntentFilter("org.monospace.smsfilter.NEW_BLOCKED_SMS"));
}

From source file:de.mtrstudios.nflpickem.UI.Highscores.HighscoresActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_highscores);

    ButterKnife.inject(this);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setTitle(getString(R.string.highscores));
    actionBar.setDisplayHomeAsUpEnabled(true);

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

    // Set up the ViewPager with the sections adapter.
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*  ww  w  .  j a  va2 s.  c  om*/
        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 < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

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

/**
 * Configures the activity tabs of the action bar.
 *//* ww  w.j ava 2 s  . com*/
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.eu.lad.JamCamViewer.JamCamViewerMainActivity.java

/**
 * Called when the activity is first created.
 *///from   ww w .j  a v a 2  s  .  co m
@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);
        }
    }

}