List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:app.sunstreak.yourpisd.MainActivity.java
private void setUpTabs() { final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab(actionBar.newTab().setText(getResources().getString(R.string.main_section_0_title)) .setTabListener(this)); actionBar.addTab(/*from w w w . ja va 2s.co m*/ actionBar.newTab().setText(TermFinder.Term.values()[CURRENT_TERM_INDEX].name).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(getResources().getString(R.string.main_section_2_title)) .setTabListener(this)); // actionBar.addTab(actionBar.newTab().setText(getResources().getString(R.string.main_section_3_title)) // .setTabListener(this)); // mViewPager // .setOnPageChangeListener(new ViewPager.OnPageChangeListener() { // @Override // public void onPageSelected(int position) { // // on changing the page // // make respected tab selected // actionBar.setSelectedNavigationItem(position); // } // // @Override // public void onPageScrolled(int arg0, float arg1, int arg2) { // } // // @Override // public void onPageScrollStateChanged(int arg0) { // } // }); }
From source file:com.tweetlanes.android.view.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { //StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDialog().build()); //StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); //StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); super.onCreate(savedInstanceState); AccountDescriptor account = getApp().getCurrentAccount(); // Attempt at fixing a crash found in HomeActivity if (account == null) { Toast.makeText(getApplicationContext(), "No cached account found, restarting", Constant.DEFAULT_TOAST_DISPLAY_TIME).show(); restartApp();//from w w w.j a v a 2 s .c om return; } ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setTitle(null); actionBar.setDisplayShowTitleEnabled(false); ArrayList<String> adapterList = new ArrayList<String>(); ArrayList<AccountDescriptor> accounts = getApp().getAccounts(); for (int i = 0; i < accounts.size(); i++) { AccountDescriptor acc = accounts.get(i); adapterList.add("@" + acc.getScreenName()); } adapterList.add(getString(R.string.add_account)); mAdapterStrings = adapterList.toArray(new String[adapterList.size()]); mSpinnerAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item, mAdapterStrings); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); actionBar.setSelectedNavigationItem(0); onCreateNavigationListener(); configureListNavigation(); mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher); updateViewVisibility(); onCreateHandleIntents(); account.setDisplayedLaneDefinitionsDirty(false); configureNotificationService(); }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
public void updateActionBar() { final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(true); final boolean showIndicator = !mShowAsDialog && (mState.action != ACTION_MANAGE); actionBar.setDisplayHomeAsUpEnabled(showIndicator); if (mDrawerToggle != null) { mDrawerToggle.setDrawerIndicatorEnabled(showIndicator); }/* w w w. j a v a 2s.c o m*/ if (isRootsDrawerOpen()) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setIcon(new ColorDrawable()); if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { actionBar.setTitle(R.string.title_open); } else if (mState.action == ACTION_CREATE) { actionBar.setTitle(R.string.title_save); } } else { final RootInfo root = getCurrentRoot(); actionBar.setIcon(root != null ? root.loadIcon(this) : null); if (mState.stack.size() <= 1) { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setTitle(root.title); } else { mIgnoreNextNavigation = true; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setTitle(null); actionBar.setListNavigationCallbacks(mStackAdapter, mStackListener); actionBar.setSelectedNavigationItem(mStackAdapter.getCount() - 1); } } }
From source file:ca.mimic.apphangar.Settings.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mInstance = this; setContentView(R.layout.activity_settings); prefs = new PrefsGet(getSharedPreferences(getPackageName(), Context.MODE_MULTI_PROCESS)); mContext = this; if (showChangelog(prefs)) { launchChangelog();/*from w w w. ja v a 2 s . c o m*/ } display = getWindowManager().getDefaultDisplay(); updateDisplayWidth(); myService = new ServiceCall(mContext); myService.setConnection(mConnection); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setTitle(R.string.title_activity_settings); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setCustomView(R.layout.action_spinner); setUpSpinner((Spinner) actionBar.getCustomView().findViewById(R.id.config_spinner)); actionBar.setDisplayShowCustomEnabled(true); mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(4); mGetFragments = new GetFragments(); mGetFragments.setFm(getFragmentManager()); mGetFragments.setVp(mViewPager); ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }; mViewPager.setOnPageChangeListener(pageChangeListener); for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } pageChangeListener.onPageSelected(GENERAL_TAB); }
From source file:com.android.contacts.activities.DialtactsActivity.java
/** * Hides every tab and shows search UI for phone lookup. *//*www . jav a 2s . c om*/ private void enterSearchUi() { if (mSearchFragment == null) { // We add the search fragment dynamically in the first onLayoutChange() and // mSearchFragment is set sometime later when the fragment transaction is actually // executed, which means there's a window when users are able to hit the (physical) // search key but mSearchFragment is still null. // It's quite hard to handle this case right, so let's just ignore the search key // in this case. Users can just hit it again and it will work this time. return; } if (mSearchView == null) { prepareSearchView(); } final ActionBar actionBar = getActionBar(); final Tab tab = actionBar.getSelectedTab(); // User can search during the call, but we don't want to remember the status. if (tab != null && !DialpadFragment.phoneIsInUse()) { mLastManuallySelectedFragment = tab.getPosition(); } mSearchView.setQuery(null, true); actionBar.setDisplayShowCustomEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowHomeEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); updateFakeMenuButtonsVisibility(false); for (int i = 0; i < TAB_INDEX_COUNT; i++) { sendFragmentVisibilityChange(i, false /* not visible */ ); } // Show the search fragment and hide everything else. mSearchFragment.setUserVisibleHint(true); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.show(mSearchFragment); transaction.commitAllowingStateLoss(); mViewPager.setVisibility(View.GONE); // We need to call this and onActionViewCollapsed() manually, since we are using a custom // layout instead of asking the search menu item to take care of SearchView. mSearchView.onActionViewExpanded(); mInSearchUi = true; }
From source file:give_me_coins.dashboard.MainScreen.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_screen); //create file for shared preference sharedPref = getSharedPreferences(getString(R.string.preference_file_key), Context.MODE_PRIVATE); API_key_saved = sharedPref.getString(getString(R.string.saved_api_key), ""); if (sharedPref.getBoolean(getString(R.string.show_ltc), true)) { coin_select = 1;//from w ww. j av a2 s .c o m } else if (sharedPref.getBoolean(getString(R.string.show_btc), true)) { coin_select = 2; } else if (sharedPref.getBoolean(getString(R.string.show_ftc), true)) { coin_select = 3; } // Start service to receive data //if(mService==null) mService= new GMCService(this,mHandler); if (mPoolService == null) mPoolService = new GMCPoolService(mHandler); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // For each of the sections in the app, add a tab to the action bar. // 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("Settings") //.setIcon(R.drawable.settings) .setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Summary") // .setIcon(R.drawable.dashboard) .setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("Pool") //.setIcon(R.drawable.news) .setTabListener(this)); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. 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); } }); actionBar.setBackgroundDrawable(new ColorDrawable(R.color.menu_background)); // mViewPager.setCurrentItem(0); if (API_key_saved != null && !API_key_saved.equals("")) { if (!"No api key found".equals(API_key_saved)) { startService(); // change to summary tab if api key is set and everything mViewPager.setCurrentItem(1); } } }
From source file:com.fitme.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Init db scheme DbHelper dbh = new DbHelper(this); dbh.createDataBase();//from w ww.ja v a 2 s. c om ActiveProgramDAO apd = new ActiveProgramDAO(this); activeProgram = apd.getActiveProgramName(); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(this); // Refresh trainings section data TrainingsSectionFragment tsf = (TrainingsSectionFragment) mAppSectionsPagerAdapter .getItem(AppSectionsPagerAdapter.SECTION_TRAININGS); tsf.onNewProgramSelected(); // Set up the action bar. final ActionBar actionBar = getActionBar(); // 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. if (actionBar != null) actionBar.setSelectedNavigationItem(position); } }); if (actionBar != 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); // 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.getTabAt(WorkoutsSectionFragment.WORKOUTS_SECTION_ID).setIcon(R.drawable.ic_section_workouts); actionBar.getTabAt(TrainingsSectionFragment.TRAININGS_SECTION_ID) .setIcon(R.drawable.ic_section_trainings); actionBar.getTabAt(DummySectionFragment.DUMMY_SECTION_ID).setIcon(R.drawable.ic_section_charts); // Additional fake tab for the future development actionBar.getTabAt(DummySectionFragment.DUMMY_SECTION_ID + 1).setIcon(R.drawable.ic_section_photo); } }
From source file:com.shafiq.mytwittle.view.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // StrictMode.setThreadPolicy(new // StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDialog().build()); // StrictMode.setThreadPolicy(new // StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build()); // StrictMode.setVmPolicy(new // StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); super.onCreate(savedInstanceState); AccountDescriptor account = getApp().getCurrentAccount(); // Attempt at fixing a crash found in HomeActivity if (account == null) { Toast.makeText(getApplicationContext(), "No cached account found, restarting", Constant.DEFAULT_TOAST_DISPLAY_TIME).show(); restartApp();/*from www . ja v a 2s . c om*/ return; } ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setTitle(null); actionBar.setDisplayShowTitleEnabled(false); ArrayList<String> adapterList = new ArrayList<String>(); ArrayList<AccountDescriptor> accounts = getApp().getAccounts(); for (int i = 0; i < accounts.size(); i++) { AccountDescriptor acc = accounts.get(i); adapterList.add("@" + acc.getScreenName() + (acc.getSocialNetType() == SocialNetConstant.Type.Appdotnet ? " (App.net)" : " (Twitter)")); } adapterList.add(getString(R.string.add_account)); mAdapterStrings = adapterList.toArray(new String[adapterList.size()]); mSpinnerAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item, mAdapterStrings); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); actionBar.setSelectedNavigationItem(0); onCreateNavigationListener(); configureListNavigation(); mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher); updateViewVisibility(); onCreateHandleIntents(); account.setDisplayedLaneDefinitionsDirty(false); configureNotificationService(); }
From source file:com.witmob.nocollapsetabs.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(); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./*from w w w. j a v a2 s . c o m*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. // 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)); } actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); }
From source file:com.android.contacts.activities.DialtactsActivity.java
/** * Goes back to usual Phone UI with tags. Previously selected Tag and associated Fragment * should be automatically focused again. *//*w ww. j a va2 s . c o m*/ private void exitSearchUi() { final ActionBar actionBar = getActionBar(); // Hide the search fragment, if exists. if (mSearchFragment != null) { mSearchFragment.setUserVisibleHint(false); final FragmentTransaction transaction = getFragmentManager().beginTransaction(); transaction.hide(mSearchFragment); transaction.commitAllowingStateLoss(); } // We want to hide SearchView and show Tabs. Also focus on previously selected one. actionBar.setDisplayShowCustomEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (int i = 0; i < TAB_INDEX_COUNT; i++) { sendFragmentVisibilityChange(i, i == mViewPager.getCurrentItem()); } // Before exiting the search screen, reset swipe state. mDuringSwipe = false; mUserTabClick = false; mViewPager.setVisibility(View.VISIBLE); hideInputMethod(getCurrentFocus()); // Request to update option menu. invalidateOptionsMenu(); // See comments in onActionViewExpanded() mSearchView.onActionViewCollapsed(); mInSearchUi = false; }