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:info.ipeanut.googletrainingcoursedemos.effectivenavigation.MainActivity.java

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

    // 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./*from   w w w .j  ava2s .c  o m*/
    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));
    }
}

From source file:com.piusvelte.cloudset.android.CloudSetMain.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(getApplicationContext());
    setContentView(R.layout.activity_main);
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(sectionsPagerAdapter);
    viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/* w w w.j  a  va 2 s .  co  m*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    for (int i = 0; i < sectionsPagerAdapter.getCount(); i++) {
        actionBar.addTab(actionBar.newTab().setText(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    SharedPreferences sp = getSharedPreferences(getString(R.string.app_name), MODE_PRIVATE);
    account = sp.getString(PREFERENCE_ACCOUNT_NAME, null);
    deviceId = sp.getLong(PREFERENCE_DEVICE_ID, INVALID_DEVICE_ID);
    setCurrentTab();

    // create the loader for registration, deregistration, and loading
    // devices
    LoaderManager loaderManager = getSupportLoaderManager();
    loaderManager.initLoader(0, null, this);

    if (savedInstanceState != null && savedInstanceState.containsKey(EXTRA_LOADER_IDS)) {
        loaderIds = savedInstanceState.getIntegerArrayList(EXTRA_LOADER_IDS);
    } else {
        loaderIds = new ArrayList<Integer>();
    }

    for (int i = 0, s = loaderIds.size(); i < s; i++) {
        // reconnect to additional loaders for deregistering additional
        // devices
        loaderManager.initLoader(loaderIds.get(i), null, this);
    }
}

From source file:com.smbc2.MainActivity.java

public 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.
    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.//from  ww w. ja  va  2 s. c o  m
    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));
    }
}

From source file:app.hacked.MainActivity.java

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

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

    actionBar.setSubtitle("This app is UNOFFICIAL");

    queue = Volley.newRequestQueue(this);

    // 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/* w ww  .  ja va  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));
    }

    //GCM stuff
    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);
    regId = GCMRegistrar.getRegistrationId(this);

    if (regId.equals("")) {
        Log.v("GCM", "Registering");
        GCMRegistrar.register(this, API.SENDER_ID);
    } else {
        Log.v("GCM", "Already registered");
    }

    //Log.e("GCMID",GCMRegistrar.getRegistrationId(this));

    JSONObject post = new JSONObject();
    try {
        post.put("gcmid", regId);
        post.put("deviceid", Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID));
    } catch (Exception e) {
        e.printStackTrace();
        Toast.makeText(this, "An Error Was encountered connecting to the GCM cloud. Chat will be unavailable",
                Toast.LENGTH_LONG).show();
        return;
    }

    JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST,
            "http://hackedioapp.networksaremadeofstring.co.uk/registergcm.php", post,
            new Response.Listener<JSONObject>() {
                @Override
                public void onResponse(JSONObject response) {
                    Log.e("response", response.toString());
                    try {
                        if (response.has("success") && response.getBoolean("success")) {
                            //Alls cool
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {

                @Override
                public void onErrorResponse(VolleyError error) {
                    // TODO Auto-generated method stub
                }
            });

    queue.add(jsObjRequest);
}

From source file:blackman.matt.infinitebrowser.NavigationDrawerFragment.java

/**
 * Per the navigation drawer design guidelines, updates the action bar to show the global app
 * 'context', rather than just what's in the current screen.
 *//*from www  .  ja v a2  s . co  m*/
private void showGlobalContextActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    //actionBar.setTitle(R.string.app_name);
}

From source file:com.example.adbird.MenuTabActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tab_menu);//from  ww w .jav a  2  s.co m
    mContext = this.getApplicationContext();

    SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
    String lang = prefs.getString("lang", null);
    Locale locale = new Locale(lang);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getBaseContext().getResources().updateConfiguration(config,
            getBaseContext().getResources().getDisplayMetrics());
    SpannableString s = new SpannableString(mContext.getResources().getString(R.string.ads_title));
    s.setSpan(new TypefaceSpan(this, "GothaProReg.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setTitle(s);
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);

            SpannableString s = new SpannableString(mAppSectionsPagerAdapter.getPageTitle(position));
            s.setSpan(new TypefaceSpan(getApplicationContext(), "GothaProReg.otf"), 0, s.length(),
                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

            actionBar.setTitle(s);
        }
    });

    // 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().setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this));

    }

}

From source file:com.agilemessage.ameffectivenavigation.MainActivity.java

@Override
public 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.
    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./*  w ww.ja  v  a  2  s . co m*/
    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
        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);
            //                Toast.makeText(getApplicationContext(), "onPageSelected, pos=" + position,
            //                        Toast.LENGTH_SHORT).show();

        }
    });

    //        // 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));
    //        }

    actionBar.addTab(actionBar.newTab().setText("about").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("share").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("go").setTabListener(this));
}

From source file:com.cachirulop.moneybox.activity.MainActivity.java

/**
 * Initialize the application action bar
 *//* www . j a  v a2 s.c om*/
private void createActionBar() {
    final ActionBar actionBar = getActionBar();

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);
}

From source file:com.semaphore.sm.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean darktheme = prefs.getBoolean("darktheme", false);
    if (darktheme)
        setTheme(android.R.style.Theme_Holo);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from   w  w  w.j a va 2s  . c  om
    // setup action bar for tabs

    try {
        ViewConfiguration config = ViewConfiguration.get(this);
        Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
        if (menuKeyField != null) {
            menuKeyField.setAccessible(true);
            menuKeyField.setBoolean(config, false);
        }
    } catch (Exception ex) {
        // Ignore
    }

    if ("mako".equals(android.os.Build.DEVICE))
        Device = SemaDevices.Mako;
    else
        Device = SemaDevices.I9000;

    if (Device == SemaDevices.Mako)
        sp = new SemaN4Properties();
    else
        sp = new SemaI9000Properties();

    checkSU_BB();
    unpackScripts();

    checkFirstRun();

    mPagerAdapter = new PagerAdapter(getSupportFragmentManager(), this);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);

    PagerTabStrip pagerTitleStrip = (PagerTabStrip) findViewById(R.id.pager_title_strip);
    pagerTitleStrip.setDrawFullUnderline(true);
    pagerTitleStrip.setTabIndicatorColor(0x33b5e5);

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);

    actionBar.setTitle("Semaphore Manager");

    actionBar.setSubtitle(SemaphoreVer);

    updateSummaries();

}

From source file:com.tabs.viewpager.testt.MainActivity.java

public 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.
    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.//  ww w  .java 2  s.  c o  m
    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));
    //        }

    //adding tab 1
    actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this));
    //adding tab 2
    actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this));
    //adding tab 2
    actionBar.addTab(actionBar.newTab().setText(R.string.title_my_profile).setTabListener(this));
}