List of usage examples for android.app ActionBar selectTab
@Deprecated public abstract void selectTab(Tab tab);
From source file:edu.pdx.cecs.orcycle.TabsConfig.java
@Override public void onResume() { super.onResume(); Log.v(MODULE_TAG, "Cycle: TabsConfig onResume"); try {/*from w w w . j ava 2 s. co m*/ final ActionBar actionBar = getActionBar(); actionBar.selectTab(actionBar.getTabAt(fragmentToShow)); myApp.ResumeNotification(); } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); } }
From source file:com.groksolutions.grok.mobile.HourDayWeekActivity.java
void restoreTabSelection() { AggregationType aggregation = HTMITApplication.getAggregation(); final ActionBar actionBar = getActionBar(); if (actionBar == null) { return;//from w ww . jav a2 s . c o m } for (int i = 0; i < actionBar.getTabCount(); i++) { Tab tab = actionBar.getTabAt(i); if (aggregation.equals(tab.getTag())) { actionBar.selectTab(tab); break; } } }
From source file:com.YOMPsolutions.YOMP.mobile.HourDayWeekActivity.java
void restoreTabSelection() { AggregationType aggregation = YOMPApplication.getAggregation(); final ActionBar actionBar = getActionBar(); if (actionBar == null) { return;/*from w w w .j av a 2 s. com*/ } for (int i = 0; i < actionBar.getTabCount(); i++) { Tab tab = actionBar.getTabAt(i); if (aggregation.equals(tab.getTag())) { actionBar.selectTab(tab); break; } } }
From source file:com.mstoyanov.music_lessons.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);/* w w w .j a v a2s .com*/ final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // if returning from an activity: if (getIntent().getStringExtra("WEEKDAY") != null) { weekday = getIntent().getStringExtra("WEEKDAY"); } if (getIntent().getIntExtra("SELECTED_TAB", 0) != 0) { selectedTab = getIntent().getIntExtra("SELECTED_TAB", 0); } mViewPager = (ViewPager) findViewById(R.id.pager); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (position == 6) { section = position; // "Students" tab actionBar.setSelectedNavigationItem(1); } else if (position == 7) { section = position; // "Add Student" tab actionBar.setSelectedNavigationItem(2); } else { section = position; // a schedule tab actionBar.setSelectedNavigationItem(0); } } }); // Add tabs to the action bar: for (int i = 0; i < 3; i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } actionBar.selectTab(actionBar.getTabAt(selectedTab)); }
From source file:com.example.office.ui.Office365DemoActivity.java
/** * Choose one of the available screens to display (via appropriate Fragment). * * @param newScreen Screen to be shown./* w ww.j a va 2 s . co m*/ */ private void switchScreen(UI.Screen newScreen) { try { ActionBar actionBar = getActionBar(); mDrawerList.setItemChecked(newScreen.ordinal(), true); setTitle(newScreen.getName(this)); actionBar.setLogo(newScreen.getIcon(this)); if (newScreen.in(ScreenGroup.MAIL)) { Screen currentScreen = Screen.getByTag(mCurrentFragmentTag, this); if (!currentScreen.in(ScreenGroup.MAIL)) { Fragment newFragment; FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); switch (newScreen) { case CONTACTS: newFragment = new ContactsFragment(); break; case MAILBOX: newFragment = new DraftsFragment(); break; case CALENDAR: { newFragment = new CalendarFragment(); break; } default: { newFragment = new DraftsFragment(); break; } } fragmentTransaction.add(R.id.content_pane, newFragment, newScreen.getName(this)); fragmentTransaction.commit(); } actionBar.selectTab(actionBar.getTabAt(newScreen.ordinal())); mCurrentFragmentTag = newScreen.getName(this); } mDrawerLayout.closeDrawer(mDrawerList); } catch (Exception e) { Logger.logApplicationException(e, getClass().getSimpleName() + ".switchBox(): Error."); } }
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 ww w . jav a 2 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; }