List of usage examples for android.app ActionBar NAVIGATION_MODE_TABS
int NAVIGATION_MODE_TABS
To view the source code for android.app ActionBar NAVIGATION_MODE_TABS.
Click Source Link
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 ww.j a v a2 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.settings.HWSettings.java
@Override protected void onCreate(Bundle savedInstanceState) { mVoiceCapable = getResources().getBoolean(com.android.internal.R.bool.config_voice_capable); if (getIntent().hasExtra(EXTRA_UI_OPTIONS)) { getWindow().setUiOptions(getIntent().getIntExtra(EXTRA_UI_OPTIONS, 0)); }/*from w w w . jav a2 s . c om*/ mAuthenticatorHelper = new AuthenticatorHelper(); mAuthenticatorHelper.updateAuthDescriptions(this); mAuthenticatorHelper.onAccountsUpdated(this, null); mDevelopmentPreferences = getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE); getMetaData(); mInLocalHeaderSwitch = true; super.onCreate(savedInstanceState); setContentView(R.layout.settings_main); mInLocalHeaderSwitch = false; /** * SPRD:Optimization to erase the animation on click. @{ */ ListView list = getListView(); list.setSelector(R.drawable.list_selector_holo_dark); /** @} */ if (!onIsHidingHeaders() && onIsMultiPane()) { highlightHeader(mTopLevelHeaderId); // Force the title so that it doesn't get overridden by a direct launch of // a specific settings screen. setTitle(R.string.settings_label); } // Retrieve any saved state if (savedInstanceState != null) { mCurrentHeader = savedInstanceState.getParcelable(SAVE_KEY_CURRENT_HEADER); mParentHeader = savedInstanceState.getParcelable(SAVE_KEY_PARENT_HEADER); if (HW_SETTINGS) { //wangkaifeng tab settings curTabIndex = savedInstanceState.getInt(SAVE_KEY_CURRENT_TAB); } } // If the current header was saved, switch to it if (savedInstanceState != null && mCurrentHeader != null) { //switchToHeaderLocal(mCurrentHeader); showBreadCrumbs(mCurrentHeader.title, null); } if (mParentHeader != null) { setParentTitle(mParentHeader.title, null, new OnClickListener() { @Override public void onClick(View v) { switchToParent(mParentHeader.fragment); } }); } // Override up navigation for multi-pane, since we handle it in the fragment breadcrumbs if (onIsMultiPane()) { getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setHomeButtonEnabled(false); } /* SPRD: add for tab style @{ */ mInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); /* @} */ /* hw settings {@ */ if (HW_SETTINGS) { //wangkaifeng tab settings createFragments(); if (this.toString().contains(".HWSettings@")) { mActionBar = getActionBar(); int tabHeight = 80;//(int) getResources().getDimensionPixelSize(R.dimen.universe_ui_tab_height); //revo lyq int TYPELCD = SystemProperties.getInt("qemu.sf.lcd_density", SystemProperties.getInt("ro.sf.lcd_density", 240)); if (TYPELCD == 160) { tabHeight = 52; } mActionBar.setAlternativeTabStyle(false); mActionBar.setTabHeight(tabHeight); setupGeneral(mActionBar); setupAll(mActionBar); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mActionBar.setDisplayShowTitleEnabled(false); mActionBar.setDisplayShowHomeEnabled(false); } } /* @} */ //liangbo add 20141231 if (FeatureOption.PRJ_FEATURE_SHOW_MENU_FOR_DEVOLOPMENT_SETTINGS) { getSharedPreferences(DevelopmentSettings.PREF_FILE, Context.MODE_PRIVATE).edit() .putBoolean(DevelopmentSettings.PREF_SHOW, true).apply(); } }
From source file:com.alirezaafkar.toolbar.ToolbarWidgetWrapper.java
@Override public void setEmbeddedTabView(ScrollingTabContainerView tabView) { if (mTabView != null && mTabView.getParent() == mToolbar) { mToolbar.removeView(mTabView);//from ww w .j a v a2 s . c om } mTabView = tabView; if (tabView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { mToolbar.addView(mTabView, 0); RtlToolbar.LayoutParams lp = (RtlToolbar.LayoutParams) mTabView.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.START | Gravity.BOTTOM; tabView.setAllowCollapse(true); } }
From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java
@Override public void setEmbeddedTabView(ScrollingTabContainerView tabView) { if (mTabView != null && mTabView.getParent() == mToolbar) { mToolbar.removeView(mTabView);//from w w w .ja v a2 s . c om } mTabView = tabView; if (tabView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) { mToolbar.addView(mTabView, 0); Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.START | Gravity.BOTTOM; tabView.setAllowCollapse(true); } }
From source file:com.example.mydemos.view.RingtonePickerActivity.java
private void setViewPager() { // need cancel these feature in onCreate requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); requestWindowFeature(Window.FEATURE_NO_TITLE); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); //using TabsPageAdapter mTabsAdapter = new TabsPageAdapter(this, mViewPager); mViewPager.setAdapter(mTabsAdapter); mViewPager.setOnPageChangeListener(mTabsAdapter); ActionBar actionBar = this.getActionBar(); Tab tab1 = actionBar.newTab();//w w w . j a v a 2 s .c o m mTabsAdapter.addTab(tab1, TabContentFragment.class, null); Tab tab2 = actionBar.newTab(); mTabsAdapter.addTab(tab2, TabContentFragment.class, null); }
From source file:com.alirezaafkar.toolbar.ToolbarWidgetWrapper.java
@Override public void setNavigationMode(int mode) { final int oldMode = mNavigationMode; if (mode != oldMode) { switch (oldMode) { case ActionBar.NAVIGATION_MODE_LIST: if (mSpinner != null && mSpinner.getParent() == mToolbar) { mToolbar.removeView(mSpinner); }/*ww w .j a v a 2s. c o m*/ break; case ActionBar.NAVIGATION_MODE_TABS: if (mTabView != null && mTabView.getParent() == mToolbar) { mToolbar.removeView(mTabView); } break; } mNavigationMode = mode; switch (mode) { case ActionBar.NAVIGATION_MODE_STANDARD: break; case ActionBar.NAVIGATION_MODE_LIST: ensureSpinner(); mToolbar.addView(mSpinner, 0); break; case ActionBar.NAVIGATION_MODE_TABS: if (mTabView != null) { mToolbar.addView(mTabView, 0); RtlToolbar.LayoutParams lp = (RtlToolbar.LayoutParams) mTabView.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.START | Gravity.BOTTOM; } break; default: throw new IllegalArgumentException("Invalid navigation mode " + mode); } } }
From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java
@Override public void setNavigationMode(int mode) { final int oldMode = mNavigationMode; if (mode != oldMode) { switch (oldMode) { case ActionBar.NAVIGATION_MODE_LIST: if (mSpinner != null && mSpinner.getParent() == mToolbar) { mToolbar.removeView(mSpinner); }//from w w w .ja v a2 s.co m break; case ActionBar.NAVIGATION_MODE_TABS: if (mTabView != null && mTabView.getParent() == mToolbar) { mToolbar.removeView(mTabView); } break; } mNavigationMode = mode; switch (mode) { case ActionBar.NAVIGATION_MODE_STANDARD: break; case ActionBar.NAVIGATION_MODE_LIST: ensureSpinner(); mToolbar.addView(mSpinner, 0); break; case ActionBar.NAVIGATION_MODE_TABS: if (mTabView != null) { mToolbar.addView(mTabView, 0); Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams(); lp.width = ViewGroup.LayoutParams.WRAP_CONTENT; lp.height = ViewGroup.LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.START | Gravity.BOTTOM; } break; default: throw new IllegalArgumentException("Invalid navigation mode " + mode); } } }
From source file:com.android.contacts.activities.DialtactsActivity.java
@Override protected void onCreate(Bundle icicle) { super.onCreate(icicle); final Intent intent = getIntent(); fixIntent(intent);//from w w w. j a v a 2 s.co m setContentView(R.layout.dialtacts_activity); mContactListFilterController = ContactListFilterController.getInstance(this); mContactListFilterController.addListener(mContactListFilterListener); findViewById(R.id.dialtacts_frame).addOnLayoutChangeListener(mFirstLayoutListener); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(new ViewPagerAdapter(getFragmentManager())); mViewPager.setOnPageChangeListener(mPageChangeListener); mViewPager.setOffscreenPageLimit(2); // Do same width calculation as ActionBar does DisplayMetrics dm = getResources().getDisplayMetrics(); int minCellSize = getResources().getDimensionPixelSize(R.dimen.fake_menu_button_min_width); int cellCount = dm.widthPixels / minCellSize; int fakeMenuItemWidth = dm.widthPixels / cellCount; if (DEBUG) Log.d(TAG, "The size of fake menu buttons (in pixel): " + fakeMenuItemWidth); // Soft menu button should appear only when there's no hardware menu button. mMenuButton = findViewById(R.id.overflow_menu); if (mMenuButton != null) { mMenuButton.setMinimumWidth(fakeMenuItemWidth); if (ViewConfiguration.get(this).hasPermanentMenuKey()) { // This is required for dialpad button's layout, so must not use GONE here. mMenuButton.setVisibility(View.INVISIBLE); } else { mMenuButton.setOnClickListener(this); } } mSearchButton = findViewById(R.id.searchButton); if (mSearchButton != null) { mSearchButton.setMinimumWidth(fakeMenuItemWidth); mSearchButton.setOnClickListener(this); } // Setup the ActionBar tabs (the order matches the tab-index contants TAB_INDEX_*) setupDialer(); setupCallLog(); setupFavorites(); getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowHomeEnabled(false); // Load the last manually loaded tab mPrefs = PreferenceManager.getDefaultSharedPreferences(this); mLastManuallySelectedFragment = mPrefs.getInt(PREF_LAST_MANUALLY_SELECTED_TAB, PREF_LAST_MANUALLY_SELECTED_TAB_DEFAULT); if (mLastManuallySelectedFragment >= TAB_INDEX_COUNT) { // Stored value may have exceeded the number of current tabs. Reset it. mLastManuallySelectedFragment = PREF_LAST_MANUALLY_SELECTED_TAB_DEFAULT; } setCurrentTab(intent); if (UI.FILTER_CONTACTS_ACTION.equals(intent.getAction()) && icicle == null) { setupFilterText(intent); } }
From source file:free.yhc.feeder.ChannelListActivity.java
@Override public void onCreate(Bundle savedInstanceState) { UnexpectedExceptionHandler.get().registerModule(this); super.onCreate(savedInstanceState); //logI("==> ChannelListActivity : onCreate"); // TODO// w ww.j a v a2 s . c o m // Is this best place to put this line of code (sendReportMail())??? // More consideration is required. // Send error report if exists. mUr.sendErrReportMail(this); // Send usage report if exists and time is passed enough. mUr.sendUsageReportMail(this); setContentView(R.layout.channel_list); setupToolButtons(); // Setup Tabs mAb = getActionBar(); mAb.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mAb.setDisplayShowTitleEnabled(false); mAb.setDisplayShowHomeEnabled(false); Feed.Category[] cats; cats = mDbp.getCategories(); eAssert(cats.length > 0); for (Feed.Category cat : cats) addCategory(cat); mPager = (ViewPager) findViewById(R.id.pager); ChannelListPagerAdapter adapter = new ChannelListPagerAdapter(getSupportFragmentManager(), cats); mPager.setAdapter(adapter); selectDefaultAsSelected(); mPager.setOnPageChangeListener(mPCListener); mDbWatcher = new DBWatcher(); }
From source file:com.native5.plugins.ActionBarPlugin.java
@Override public boolean execute(final String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException { if (!plugin_actions.contains(action)) { return false; }/*from w w w . j a v a2 s . c om*/ final Activity ctx = (Activity) cordova; if ("isAvailable".equals(action)) { JSONObject result = new JSONObject(); result.put("value", ctx.getWindow().hasFeature(Window.FEATURE_ACTION_BAR)); callbackContext.success(result); return true; } final ActionBar bar = ctx.getActionBar(); if (bar == null) { Window window = ctx.getWindow(); if (!window.hasFeature(Window.FEATURE_ACTION_BAR)) { callbackContext .error("ActionBar feature not available, Window.FEATURE_ACTION_BAR must be enabled!"); } else { callbackContext.error("Failed to get ActionBar"); } return true; } if (menu == null) { callbackContext.error("Options menu not initialised"); return true; } final StringBuffer error = new StringBuffer(); JSONObject result = new JSONObject(); if ("isShowing".equals(action)) { result.put("value", bar.isShowing()); } else if ("getHeight".equals(action)) { result.put("value", bar.getHeight()); } else if ("getDisplayOptions".equals(action)) { result.put("value", bar.getDisplayOptions()); } else if ("getNavigationMode".equals(action)) { result.put("value", bar.getNavigationMode()); } else if ("getSelectedNavigationItem".equals(action)) { result.put("value", bar.getSelectedNavigationIndex()); } else if ("getSubtitle".equals(action)) { result.put("value", bar.getSubtitle()); } else if ("getTitle".equals(action)) { result.put("value", bar.getTitle()); } else { try { JSONException exception = new Runnable() { public JSONException exception = null; public void run() { try { // This is a bit of a hack (should be specific to the request, not global) bases = new String[] { removeFilename(webView.getOriginalUrl()), removeFilename(webView.getUrl()) }; if ("show".equals(action)) { LOG.d("native5-action-bar", "Showing Action Bar"); bar.show(); } else if ("hide".equals(action)) { bar.hide(); } else if ("setMenu".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } menu_definition = args.getJSONArray(0); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ctx.invalidateOptionsMenu(); } } else if ("setTabs".equals(action)) { if (args.isNull(0)) { error.append("menu can not be null"); return; } bar.removeAllTabs(); tab_callbacks.clear(); if (!buildTabs(bar, args.getJSONArray(0))) { error.append("Invalid tab bar definition"); } } else if ("setDisplayHomeAsUpEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHomeAsUp can not be null"); return; } bar.setDisplayHomeAsUpEnabled(args.getBoolean(0)); } else if ("setDisplayOptions".equals(action)) { if (args.isNull(0)) { error.append("options can not be null"); return; } final int options = args.getInt(0); bar.setDisplayOptions(options); } else if ("setDisplayShowHomeEnabled".equals(action)) { if (args.isNull(0)) { error.append("showHome can not be null"); return; } bar.setDisplayShowHomeEnabled(args.getBoolean(0)); } else if ("setDisplayShowTitleEnabled".equals(action)) { if (args.isNull(0)) { error.append("showTitle can not be null"); return; } bar.setDisplayShowTitleEnabled(args.getBoolean(0)); } else if ("setDisplayUseLogoEnabled".equals(action)) { if (args.isNull(0)) { error.append("useLogo can not be null"); return; } bar.setDisplayUseLogoEnabled(args.getBoolean(0)); } else if ("setHomeButtonEnabled".equals(action)) { if (args.isNull(0)) { error.append("enabled can not be null"); return; } bar.setHomeButtonEnabled(args.getBoolean(0)); } else if ("setIcon".equals(action)) { if (args.isNull(0)) { error.append("icon can not be null"); return; } Drawable drawable = getDrawableForURI(args.getString(0)); bar.setIcon(drawable); } else if ("setListNavigation".equals(action)) { JSONArray items = null; if (args.isNull(0) == false) { items = args.getJSONArray(0); } navigation_adapter.setItems(items); bar.setListNavigationCallbacks(navigation_adapter, navigation_listener); } else if ("setLogo".equals(action)) { String uri = args.getString(0); if (args.isNull(0)) { error.append("logo can not be null"); return; } // try { // InputStream ims = ctx.getAssets().open(uri); Drawable drawable = getDrawableForURI(uri); // Drawable.createFromStream(ims, null); bar.setLogo(drawable); bar.setBackgroundDrawable(getDrawableForURI("images/logo-bg.png")); // } catch (IOException e) { // e.printStackTrace(); // } } else if ("setNavigationMode".equals(action)) { if (args.isNull(0)) { error.append("mode can not be null"); return; } final int mode = args.getInt(0); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else if ("setSelectedNavigationItem".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } bar.setSelectedNavigationItem(args.getInt(0)); } else if ("setSelectedTab".equals(action)) { if (args.isNull(0)) { error.append("position can not be null"); return; } LOG.d("setSelectedTab", bar.getTabCount() + ""); bar.selectTab(bar.getTabAt(args.getInt(0))); } else if ("setSubtitle".equals(action)) { if (args.isNull(0)) { error.append("subtitle can not be null"); return; } bar.setSubtitle(args.getString(0)); } else if ("setTitle".equals(action)) { if (args.isNull(0)) { error.append("title can not be null"); return; } bar.setTitle(args.getString(0)); } } catch (JSONException e) { exception = e; } finally { synchronized (this) { this.notify(); } } } // Run task synchronously { synchronized (this) { ctx.runOnUiThread(this); this.wait(); } } }.exception; if (exception != null) { throw exception; } } catch (InterruptedException e) { error.append("Function interrupted on UI thread"); } } if (error.length() == 0) { if (result.length() > 0) { callbackContext.success(result); } else { callbackContext.success(); } } else { callbackContext.error(error.toString()); } return true; }