List of usage examples for android.app ActionBar getTabAt
@Deprecated public abstract Tab getTabAt(int index);
From source file:com.groksolutions.grok.mobile.HourDayWeekActivity.java
void restoreTabSelection() { AggregationType aggregation = HTMITApplication.getAggregation(); final ActionBar actionBar = getActionBar(); if (actionBar == null) { return;/*from ww w. j a va 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.YOMPsolutions.YOMP.mobile.HourDayWeekActivity.java
void restoreTabSelection() { AggregationType aggregation = YOMPApplication.getAggregation(); final ActionBar actionBar = getActionBar(); if (actionBar == null) { return;//w w w.j a v a 2 s . co 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:edu.pdx.cecs.orcycle.TabsConfig.java
@Override public void onResume() { super.onResume(); Log.v(MODULE_TAG, "Cycle: TabsConfig onResume"); try {//from w ww . ja va 2 s. c om final ActionBar actionBar = getActionBar(); actionBar.selectTab(actionBar.getTabAt(fragmentToShow)); myApp.ResumeNotification(); } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); } }
From source file:org.dmfs.webcal.fragments.MyCalendarsFragment.java
private void setupActionBarTabs() { ActionBar actionBar = getActivity().getActionBar(); int tabCount = actionBar.getTabCount(); int pageCount = mAdapter.getCount(); // replace titles and listeners of existing tabs int i = 0;/*from www.java2s. co m*/ for (; i < tabCount && i < pageCount; ++i) { final Tab tab = actionBar.getTabAt(i); tab.setText(mAdapter.getPageTitle(i)); tab.setTabListener(this); } // add missing tabs for (; i < pageCount; ++i) { actionBar.addTab(actionBar.newTab().setText(mAdapter.getPageTitle(i)).setTabListener(this)); } // remove remaining tabs for (; i < tabCount; --tabCount) { actionBar.removeTabAt(i); } if (pageCount > 1) { int selection = mSelectedTab; // changing the navigation mode might trigger a call to onTabSelected, overriding mSelectedTab with a wrong value, so save it actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mSelectedTab = selection; if (selection < pageCount) { mViewPager.setCurrentItem(selection, false); } } else { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } }
From source file:org.dmfs.webcal.fragments.PagerFragment.java
/** * Configures the tabs on the action bar. *//* w w w. j ava2 s . c om*/ private void setupActionBarTabs() { ActionBar actionBar = getActivity().getActionBar(); int tabCount = actionBar.getTabCount(); int pageCount = mAdapter.getCount(); // replace titles and listeners of existing tabs int i = 0; for (; i < tabCount && i < pageCount; ++i) { final Tab tab = actionBar.getTabAt(i); tab.setText(mAdapter.getPageTitle(i)); tab.setTabListener(this); } // add missing tabs for (; i < pageCount; ++i) { actionBar.addTab(actionBar.newTab().setText(mAdapter.getPageTitle(i)).setTabListener(this)); } // remove remaining tabs for (; i < tabCount; --tabCount) { actionBar.removeTabAt(i); } if (pageCount > 1) { int selection = mSelectedTab; // changing the navigation mode might trigger a call to onTabSelected overriding mSelectedTab with a wrong value, so save it actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mSelectedTab = selection; if (selection < pageCount) { mViewPager.setCurrentItem(selection, false); } } else { actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); } }
From source file:com.github.wakhub.monodict.activity.FlashcardActivity.java
@UiThread void reloadTabs() { Map<Integer, Integer> countsForBoxes; try {/* w w w .j a v a 2 s . c o m*/ countsForBoxes = databaseHelper.getCountsForBoxes(); } catch (SQLException e) { activityHelper.showError(e); return; } ActionBar actionBar = getActionBar(); for (int i = 0; i < Card.BOX_MAX; i++) { ActionBar.Tab tab; if (actionBar.getTabCount() > i) { tab = actionBar.getTabAt(i); } else { tab = actionBar.newTab().setTag(i).setTabListener(this); actionBar.addTab(tab); } int box = i + 1; String label = String.format("BOX%d", box); if (i == 0) { label = "INBOX"; } if (countsForBoxes.keySet().contains(box)) { label += String.format("(%d)", countsForBoxes.get(box)); } tab.setText(label); } if (!isTabInitialized || isReloadRequired) { isTabInitialized = true; isReloadRequired = false; // TODO: not working int index = state.getBox() - 1; if (index < 0 || actionBar.getTabCount() < index) { index = 0; } actionBar.getTabAt(index).select(); loadContents(); } }
From source file:com.groksolutions.grok.mobile.HourDayWeekActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(getResourceView());//from ww w . j a v a 2 s . c o m // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); Locale l = Locale.getDefault(); // For each of the sections in the app, add a tab to the action bar. // Add the "Fragment" class to the tab's tag. The tab's "Fragment" will // be created using this class // Hour Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_hour).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Hour)); // Day Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_day).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Day)); // Week Page actionBar.addTab(actionBar.newTab().setText(getString(R.string.title_tab_week).toUpperCase(l)) .setTabListener(this).setTag(AggregationType.Week)); // Create the fragment adapter that will return a fragment based on the // Fragment class attached to the tab's tag object final FragmentPagerAdapter pagerAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) { final Fragment[] _fragments = new Fragment[3]; @Override public Fragment getItem(int position) { Tab tab = actionBar.getTabAt(position); if (tab != null) { if (_fragments[position] == null) { _fragments[position] = createTabFragment(tab); } } return _fragments[position]; } @Override public int getCount() { return actionBar.getTabCount(); } }; // Set up the ViewPager with the sections adapter. _viewPager = (ViewPager) findViewById(R.id.pager); _viewPager.setAdapter(pagerAdapter); // Keep all pages in memory _viewPager.setOffscreenPageLimit(2); // 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. _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); }
From source file:name.gumartinm.weather.information.activity.MainTabsActivity.java
@Override public void onResume() { super.onResume(); final SharedPreferences sharedPreferences = PreferenceManager .getDefaultSharedPreferences(this.getApplicationContext()); final String APPID = sharedPreferences.getString(this.getString(R.string.weather_preferences_app_id_key), "");// w ww . ja v a 2 s .c o m final String noticeKeyPreference = this.getString(R.string.api_id_key_notice_preference_key); final boolean notice = sharedPreferences.getBoolean(noticeKeyPreference, true); if (notice && APPID.isEmpty()) { final FragmentManager fm = this.getSupportFragmentManager(); final Fragment buttonsFragment = fm.findFragmentByTag("noticeDialog"); if (buttonsFragment == null) { final DialogFragment newFragment = APIKeyNoticeDialogFragment .newInstance(R.string.api_id_key_notice_title); newFragment.setRetainInstance(true); newFragment.setCancelable(false); newFragment.show(fm, "noticeDialog"); } } final ActionBar actionBar = this.getActionBar(); // 1. Update title. final DatabaseQueries query = new DatabaseQueries(this.getApplicationContext()); final WeatherLocation weatherLocation = query.queryDataBase(); if (weatherLocation != null) { final String[] array = new String[2]; array[0] = weatherLocation.getCity(); array[1] = weatherLocation.getCountry(); final MessageFormat message = new MessageFormat("{0},{1}", Locale.US); final String cityCountry = message.format(array); actionBar.setTitle(cityCountry); } else { actionBar.setTitle(this.getString(R.string.text_field_no_chosen_location)); } // 2. Update forecast tab text. final String keyPreference = this.getString(R.string.weather_preferences_day_forecast_key); final String value = sharedPreferences.getString(keyPreference, ""); String humanValue = ""; if (value.equals(this.getString(R.string.weather_preferences_day_forecast_five_day))) { humanValue = this.getString(R.string.text_tab_five_days_forecast); } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_ten_day))) { humanValue = this.getString(R.string.text_tab_ten_days_forecast); } else if (value.equals(this.getString(R.string.weather_preferences_day_forecast_fourteen_day))) { humanValue = this.getString(R.string.text_tab_fourteen_days_forecast); } actionBar.getTabAt(1).setText(humanValue); }
From source file:com.mstoyanov.music_lessons.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w .ja v a 2 s. c o m 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 w w .j ava 2s . c om */ 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."); } }