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.schedule.ScheduleActivity.java

/**
 * Sets up Action Bar (if present)./*from   w  w w  .  ja v  a 2  s.c o  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:no.invisibleink.app.MainActivity.java

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

    /* -------------------------------- Init ---------------- */
    serverManager = new ServerManager();
    locationManager = new LocationManager(this);
    locationManager.onCreate();/*w w  w . j  a v a 2 s  .  c  o m*/

    /* -------------------------------- Swipe view with taps ---------------- */
    fragmentManager = getSupportFragmentManager();

    listSectionFragment = new ListViewFragment();
    mapSectionFragment = new MapViewFragment();
    postSectionFragment = new PostViewFragment();

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

    // 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);
        }
    });
    /*
     * Set the number of pages that should be retained to either side of the
     * current page in the view hierarchy in an idle state. Pages beyond
     * this limit will be recreated from the adapter when needed.
     */
    mViewPager.setOffscreenPageLimit(3);

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

    try {
        MapsInitializer.initialize(getApplicationContext());
    } catch (GooglePlayServicesNotAvailableException e) {
        Log.e(TAG, "Google play services is not available.");
    }
}

From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java

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

    // 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/* www .  j a  va 2  s.  com*/
        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));
    }

    SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE);
    ;
    SharedPreferences.Editor editor = settings.edit();

    // load the default parameters into SharedPreferences for the first time launch 
    int ct = settings.getInt("count", 0);
    if (ct == 0) {
        editor.putString("start", "9");
        editor.putString("end", "21");
        editor.putString("interval", "15");
        editor.putString("duration", "5");
        editor.putString("location", "On");
        editor.putString("upload", "On");
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        editor.putString("IMEI", tm.getDeviceId());
        editor.putString("brand", Build.BRAND);
        editor.putString("model", Build.MODEL);
        String phone_type = Build.BRAND + "_" + Build.MODEL;

        // motoX
        if (phone_type.equals("motorola_XT1058")) {
            editor.putString("mfcc_dist_same_semi", "13");
            editor.putString("mfcc_dist_diff_semi", "18");
            editor.putString("mfcc_dist_same_un", "13");
            editor.putString("mfcc_dist_diff_un", "18");
        }
        // nexus 4
        else if (phone_type.equals("google_Nexus 4")) {
            editor.putString("mfcc_dist_same_semi", "17");
            editor.putString("mfcc_dist_diff_semi", "22");
            editor.putString("mfcc_dist_same_un", "17");
            editor.putString("mfcc_dist_diff_un", "22");
        }
        // s2
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) {
            editor.putString("mfcc_dist_same_semi", "18");
            editor.putString("mfcc_dist_diff_semi", "25");
            editor.putString("mfcc_dist_same_un", "18");
            editor.putString("mfcc_dist_diff_un", "25");
        }
        // s3 
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) {
            editor.putString("mfcc_dist_same_semi", "16");
            editor.putString("mfcc_dist_diff_semi", "21");
            editor.putString("mfcc_dist_same_un", "16");
            editor.putString("mfcc_dist_diff_un", "21");
        }
        // s4
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) {
            editor.putString("mfcc_dist_same_semi", "14");
            editor.putString("mfcc_dist_diff_semi", "24");
            editor.putString("mfcc_dist_same_un", "14");
            editor.putString("mfcc_dist_diff_un", "24");
        }
        // other devices
        else {
            editor.putString("mfcc_dist_same_semi", "15.6");
            editor.putString("mfcc_dist_diff_semi", "21.6");
            editor.putString("mfcc_dist_same_un", "15.6");
            editor.putString("mfcc_dist_diff_un", "21.6");
            Toast.makeText(this, "Your device is not recognized and the result might not be accurate...",
                    Toast.LENGTH_SHORT).show();
        }
        Log.i("Crowd++", "First time launched");

        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("Welcome to Crowd++");
        dialog.setMessage(Constants.hello_msg);
        dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        dialog.show();
        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20);
    }

    editor.putInt("count", ++ct);
    editor.commit();
    Log.i("Launched Count", Integer.toString(ct));
    mConst = new Constants(this);
    if (!Constants.calibration())
        Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show();
}

From source file:co.edu.uniajc.vtf.content.SwipeContentActivity.java

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

    //get the pager
    this.coAppSectionsPagerAdapter = new AppSectionsPagerAdapter(this.getSupportFragmentManager(), this);
    this.coViewPager = (ViewPager) findViewById(R.id.pagPagerContainer);
    this.coViewPager.setAdapter(coAppSectionsPagerAdapter);

    //get the action bar
    final ActionBar actionBar = this.getActionBar();
    coViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override/*from  w  w w.j av a2 s . c o  m*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    actionBar.setHomeButtonEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.list48));
    actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.map48));
    actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.ra48));
    actionBar.addTab(actionBar.newTab().setTabListener(this).setIcon(R.drawable.options48));

    //get the google api client 
    this.coApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this).addApi(Plus.API).addScope(Plus.SCOPE_PLUS_PROFILE).build();
}

From source file:com.example.administrator.myapplication2._3_HB._3_MainActivity.java

/*****************************************************
 *    Overrided methods//from  w  ww  . ja  va2  s.co m
 ******************************************************/

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

    requestWindowFeature(Window.FEATURE_ACTION_BAR);
    //----- System, Context
    mContext = this; //.getApplicationContext();
    mActivityHandler = new ActivityHandler();
    AppSettings.initializeAppSettings(mContext);

    setContentView(R.layout._3_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 primary sections of the app.
    mFragmentManager = getSupportFragmentManager();
    mSectionsPagerAdapter = new FragmentAdapter(mFragmentManager, mContext, this, mActivityHandler);

    // 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.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        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.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    // Setup views
    mImageBT = (ImageView) findViewById(R.id.status_title);
    mImageBT.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_invisible));
    mTextStatus = (TextView) findViewById(R.id.status_text);
    mTextStatus.setText(getResources().getString(R.string.bt_state_init));

    // Do data initialization after service started and binded
    doStartService();
}

From source file:com.scto.filerenamer.FileRenamerActivity.java

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

    mSettings = Prefs.getSharedPreferences(this);
    mSettings.registerOnSharedPreferenceChangeListener(this);

    if (Prefs.getThemeType(this) == false) {
        mThemeId = R.style.AppTheme_Light;
        setTheme(mThemeId);/*from   w  w w  .j av a  2  s  . c  om*/
    } else {
        mThemeId = R.style.AppTheme_Dark;
        setTheme(mThemeId);
    }

    ActionBar mActionBar = getActionBar();
    if (mActionBar != null) {
        mActionBar.setDisplayHomeAsUpEnabled(true);
        mActionBar.setDisplayShowHomeEnabled(true);
        mActionBar.setDisplayShowTitleEnabled(true);
        mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    } else {
        if (BuildConfig.DEBUG) {
            Log.w("[" + TAG + "]", "mActionBar == null");
        }
    }

    setContentView(R.layout.fragment_tabs_pager);

    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();

    mViewPager = (ViewPager) findViewById(R.id.pager);

    mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager);

    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.addNumber)).setIndicator(getString(R.string.addNumber)),
            AddNumbersFragment.class, null);
    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.addCustom)).setIndicator(getString(R.string.addCustom)),
            AddCustomFragment.class, null);
    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.addDate)).setIndicator(getString(R.string.addDate)),
            AddCharsFragment.class, null);
    mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.findAndReplace))
            .setIndicator(getString(R.string.findAndReplace)), AddDateFragment.class, null);
    mTabsAdapter.addTab(
            mTabHost.newTabSpec(getString(R.string.removeChars)).setIndicator(getString(R.string.removeChars)),
            RemoveCharsFragment.class, null);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name));
    } else {
        if (BuildConfig.DEBUG) {
            Log.w("[" + TAG + "]", "onCreate( savedInstanceState ) : extras == null");
        }
        this.setTitle(" :: " + getString(R.string.app_name));
    }

    if (savedInstanceState != null) {
        mActionBar.setSelectedNavigationItem(savedInstanceState.getInt("action_bar_tab", 0));
        mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab_host"));
    }
}

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

/**
 * Initialize the activity action bar//from   w  w  w. j av  a2 s . c  o m
 */
private void createActionBar() {
    final ActionBar actionBar = getActionBar();

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

From source file:fr.cph.chicago.activity.MainActivity.java

/**
 * Restore action bar// w ww. jav a  2s .  c o m
 */
public final void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);
}

From source file:com.pld.h4414.sportify.ViewPagerActivity.java

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

    // 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 buttonProfile should not be enabled, since there is no hierarchical
    // parent./*w  w w .  j ava 2  s . co 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().setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this));
    }

    /*
    That will be used for v2 or next
            
            
    FloatingActionButton fabButton = new FloatingActionButton.Builder(this)
        .withDrawable(getResources().getDrawable(R.drawable.ic_add))
        .withButtonColor(Color.WHITE)
        .withGravity(Gravity.BOTTOM | Gravity.RIGHT)
        .withMargins(0, 0, 16, 16)
        .create();
    */

}

From source file:com.owo.android.mtPlease.MainActivity.java

@Override
public 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);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // setting for the sidedrawer
    // set the content view
    setBehindContentView(R.layout.drawer_search);
    getSlidingMenu().setFadeEnabled(true);
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setFadeDegree(0.90f);

    searchDrawerCloseButton = (ImageButton) findViewById(R.id.button_search_drawer_close);
    searchDrawerCloseButton.setOnClickListener(new OnClickListener() {

        @Override//w w w.j a  v a  2s.c om
        public void onClick(View v) {
            // TODO Auto-generated method stub
            getSlidingMenu().showContent();
        }

    });

    // 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
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    //         
    mViewPager.setOffscreenPageLimit(3);

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

    locationSelectSpinner = (Spinner) findViewById(R.id.spinner_location);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.location_array,
            R.layout.spinner_text);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    locationSelectSpinner.setAdapter(adapter);

    datePickerButton = (Button) findViewById(R.id.button_datepicker);
    datePickerButton.setText(modifiedDate);
    datePickerButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            FragmentManager dialogManager = getFragmentManager();
            CalendarDialogFragment calendarDialogFragment = new CalendarDialogFragment();
            calendarDialogFragment.setParentCaller(CalendarDialogFragment.PARENT_IS_ACTIVITY);
            calendarDialogFragment.show(dialogManager, "calendar_dialog_popped");
        }

    });
    // Activity    emailAddress(SESSION_ID)  MyPageFragment
    // .

    //    
    searchButton = (ImageButton) findViewById(R.id.imageButton_search);
    searchButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            try {
                String region = locationSelectSpinner.getSelectedItem().toString();
                if (region.equals("")) {
                    region = "1";
                } else if (region.equals("")) {
                    region = "2";
                } else {
                    region = "3";
                }

                String people = ((EditText) findViewById(R.id.editText_numberPeople)).getText().toString();

                String[] tmp = (datePickerButton.getText().toString()).split(" ");
                String date = tmp[0].substring(0, 4) + "-" + tmp[1].split("")[0] + "-"
                        + tmp[2].split("")[0];

                String query = "?region=" + region + "&people=" + people + "&date=" + date + "&flag=1";
                sendInfoToFragment(people, 2);
                sendInfoToFragment(query, 0);

                getSlidingMenu().showContent();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                Toast.makeText(getApplicationContext(), "  ", Toast.LENGTH_SHORT);
                e.printStackTrace();
            }
        }

    });

}