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.xenon.greenup.MainActivity.java

public void onCreate(Bundle savedInstanceState) {

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

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

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

    //Set the stacked background otherwise we get the gross dark gray color under the icon
    BitmapDrawable background = (BitmapDrawable) getResources().getDrawable(R.drawable.bottom_menu);
    background.setTileModeXY(TileMode.REPEAT, TileMode.MIRROR);
    actionBar.setStackedBackgroundDrawable(background);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setIcon(R.drawable.bottom_menu);

    _ViewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabsAdapter(this, _ViewPager);

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < 3; 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
        // listener for when this tab is selected.

        ActionBar.Tab tabToAdd = actionBar.newTab();
        if (i == 0)
            //Set the home page as active since we'll start there:
            tabToAdd.setIcon(getActiveIcon(i));
        else/*from w w w  .j av  a2 s  .  c  o m*/
            tabToAdd.setIcon(getRegularIcon(i));
        mTabsAdapter.addTab(tabToAdd);

    }

    //Setting the display to custom will push the action bar to the top
    //which gives us more real estate
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    actionBar.show();
    Log.i("visible", "" + _ViewPager.VISIBLE);

}

From source file:org.ounl.lifelonglearninghub.nfcecology.fcube.navigate.SwipeFragmentActivity.java

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

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

    // Actvate home button
    final ActionBar actionBar = getActionBar();
    actionBar.setHomeButtonEnabled(true);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // 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(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from  w  w  w.j  a v a  2s.  c o 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);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.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
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

}

From source file:it.durip_app.MACActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_mac);
    data = new MACSource();
    isIperfRunning = isIperfRunning();// w w w . ja va2 s.co  m
    isOlsrRunning = isOlsrRunning();
    // Get the message from the intent
    Intent intent = getIntent();
    paramUrl = intent.getStringExtra(MainActivity.PARAM_URL);
    paramT = intent.getIntExtra(MainActivity.PARAM_T, 200);
    paramI = intent.getIntExtra(MainActivity.PARAM_I, 5);
    paramMAC = intent.getStringExtra(MainActivity.PARAM_MAC);
    paramSleep = intent.getIntExtra(MainActivity.PARAM_SLEEP, 500);
    paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000);
    paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1);
    data.setUrl(paramUrl);
    data.setT(paramT);
    data.setI(paramI);
    data.setPort(paramPort);
    data.setSleep(paramSleep);
    data.setVerbose(paramVerbose);
    data.setMAC(paramMAC);
    // kick off the data generating thread:
    //mySource = new Thread(data);
    //mySource.start();
    data.startMAC();

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

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

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

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // 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(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        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);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.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
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    // Show the Up button in the action bar.

}

From source file:net.lacolaco.smileessence.activity.MainActivity.java

private void initializeView() {
    ActionBar bar = getActionBar();
    bar.setDisplayShowHomeEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    pagerAdapter = new PageListAdapter(this, viewPager);
    initializePages();// w  w w  .  j a v  a 2  s.c om
}

From source file:com.concentricsky.android.khanacademy.app.ManageDownloadsActivity.java

@Override
protected void onStart() {
    super.onStart();

    gridView = (GridView) findViewById(R.id.grid);
    gridView.setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
    gridView.setMultiChoiceModeListener(multiChoiceModeListener);
    gridView.setOnItemClickListener(itemClickListener);

    View emptyView = getLayoutInflater().inflate(R.layout.listview_empty, null, false);
    ((TextView) emptyView.findViewById(R.id.text_list_empty)).setText(R.string.msg_no_downloaded_videos);
    ViewGroup.LayoutParams p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT);
    addContentView(emptyView, p);/*w  w  w  .jav a 2s. c om*/

    gridView.setEmptyView(emptyView);

    requestDataService(new ObjectCallback<KADataService>() {
        @Override
        public void call(final KADataService dataService) {
            ManageDownloadsActivity.this.dataService = dataService;

            CursorAdapter adapter = new Adapter(ManageDownloadsActivity.this, null, 0,
                    dataService.getThumbnailManager());
            gridView.setAdapter(adapter);

            new AsyncTask<Void, Void, Cursor>() {
                @Override
                protected Cursor doInBackground(Void... arg) {
                    return getCursor();
                }

                @Override
                protected void onPostExecute(Cursor cursor) {
                    ((CursorAdapter) gridView.getAdapter()).changeCursor(cursor);
                }
            }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);

            final ActionBar ab = getActionBar();
            ab.setDisplayHomeAsUpEnabled(true);

            ab.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            ab.setTitle("");

            setupListNavigation();

            // The receiver performs actions that require a dataService, so register it here.
            IntentFilter filter = new IntentFilter();
            filter.addAction(ACTION_LIBRARY_UPDATE);
            filter.addAction(ACTION_BADGE_EARNED);
            filter.addAction(ACTION_OFFLINE_VIDEO_SET_CHANGED);
            filter.addAction(ACTION_DOWNLOAD_PROGRESS_UPDATE);
            filter.addAction(ACTION_TOAST);
            broadcastManager.registerReceiver(receiver, filter);
        }
    });
}

From source file:com.example.office.ui.Office365DemoActivity.java

/**
 * Initializes activity UI elements./*  ww  w. j  a  v a2  s .c  o m*/
 */
private void initUi() {
    if (!mIsInitialized) {
        setContentView(R.layout.main_activity);

        mTitle = mDrawerTitle = getTitle();

        // Setting up Action Bar and Tabs.
        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setLogo(R.drawable.ic_action_mail);

        Tab tab = actionBar.newTab().setText(UI.Screen.CONTACTS.getName(this))
                .setTag(UI.Screen.CONTACTS.getName(this)).setTabListener(new TabListener<ContactsFragment>(this,
                        UI.Screen.CONTACTS.getName(this), ContactsFragment.class));
        actionBar.addTab(tab);

        tab = actionBar.newTab().setText(UI.Screen.MAILBOX.getName(this))
                .setTag(UI.Screen.MAILBOX.getName(this)).setTabListener(new TabListener<DraftsFragment>(this,
                        UI.Screen.MAILBOX.getName(this), DraftsFragment.class));
        actionBar.addTab(tab, true);

        tab = actionBar.newTab().setText(UI.Screen.CALENDAR.getName(this))
                .setTag(UI.Screen.CALENDAR.getName(this)).setTabListener(new TabListener<CalendarFragment>(this,
                        UI.Screen.CALENDAR.getName(this), CalendarFragment.class));
        actionBar.addTab(tab);

        // Setting up sliding drawer.
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
        mDrawerList = (ListView) findViewById(R.id.left_drawer);

        SlidingDrawerAdapter drawerAdapter = new SlidingDrawerAdapter(OfficeApplication.getContext(),
                R.layout.drawer_list_item, R.layout.drawer_delimiter);
        mDrawerList.setAdapter(drawerAdapter);

        mDrawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                try {
                    Screen[] drawerScreens = ScreenGroup.DRAWER.getMembers().toArray(new Screen[0]);
                    Screen currentScreen = DEFAULT_SCREEN;

                    // use id instead of position here because some positions used by delimiters, id contains real index of clicked item
                    if (drawerScreens != null && drawerScreens.length - 1 >= id) {
                        currentScreen = drawerScreens[(int) id];
                    }
                    switchScreen(currentScreen);
                } catch (Exception e) {
                    Logger.logApplicationException(e, getClass().getSimpleName() + "onItemClick(): Error.");
                }
            }
        });

        actionBar.setHomeButtonEnabled(true);

        // ActionBarDrawerToggle ties together the the proper interactions
        // between the sliding drawer and the action bar app icon
        mDrawerToggle = new ActionBarDrawerToggle(this,
                /* host Activity */mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer, /* drawer navigation image replacing '<' */
                R.string.drawer_open, R.string.drawer_close) {
            public void onDrawerClosed(View view) {
                getActionBar().setTitle(mTitle);
                invalidateOptionsMenu();
            }

            public void onDrawerOpened(View drawerView) {
                getActionBar().setTitle(mDrawerTitle);
                invalidateOptionsMenu();
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        mIsInitialized = true;
    }

    if (mSavedFragmentTag == null) {
        switchScreen(DEFAULT_SCREEN);
    } else {
        // This is not used mostly as we're going back to this activity when it
        // is at the top of the back stack. So (as it does have 'singleTop' in parameters) it is
        // simply restored and onNewIntent() is called instead of onCreate().
        // So savedInstanceState will usually be null. This is added to anticipate other future use cases.
        switchScreen(Screen.getByTag(mSavedFragmentTag, this));
    }
}

From source file:com.tweetlanes.android.view.HomeActivity.java

private boolean configureListNavigation() {

    if (mSpinnerAdapter == null) {
        return false;
    }/*from   ww w.ja  v  a  2s  . co m*/

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    int accountIndex = 0;
    AccountDescriptor currentAccount = getApp().getCurrentAccount();
    if (currentAccount != null) {
        String testScreenName = "@" + currentAccount.getScreenName().toLowerCase();
        for (int i = 0; i < mAdapterStrings.length; i++) {
            if (testScreenName.equals(mAdapterStrings[i].toLowerCase())) {
                accountIndex = i;
                break;
            }
        }
    }
    actionBar.setSelectedNavigationItem(accountIndex);
    actionBar.setDisplayHomeAsUpEnabled(false);
    return true;
}

From source file:com.example.jenil.parsedemo.GamePlayActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_game_play);

    Intent intent = getIntent();/*from   w  w w  .  java  2 s  .  c  o m*/
    Phrase = intent.getStringExtra("MOVIE");
    words = Phrase.split(" ");

    opponent = intent.getStringExtra("OPPONENT");

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

    // Set up the action bar.

    final ActionBar actionBar = getActionBar();

    if (actionBar == null) {
        Log.i("ALERT", "NULL");
    } else {
        Log.i("ALERT", "NOT NULL");
    }

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

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // 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(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        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);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.getCount() - 1; 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
        // listener for when this tab is selected.
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
    actionBar.addTab(actionBar.newTab().setText("Submit").setTabListener(this));

}

From source file:com.android.gpstest.GpsTestActivity.java

private void initActionBar(Bundle savedInstanceState) {
    // Set up the action bar.
    final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setTitle(getApplicationContext().getText(R.string.app_name));

    // If we don't have a large screen, set up the tabs using the ViewPager
    if (!mIsLargeScreen) {
        //  page adapter contains all the fragment registrations
        mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

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

        // 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 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 listener for when this tab is
            // selected.
            actionBar.addTab(
                    actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
        }
    }
}