List of usage examples for android.app ActionBar newTab
@Deprecated public abstract Tab newTab();
From source file:de.toshsoft.tsremote.configuration.ConfigurationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // Remove all StandOut Windows StandOutWindow.closeAll(this, StandOutRemoteActivity.class); super.onCreate(savedInstanceState); setContentView(R.layout.configuration_activity); // 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 three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // 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//ww w. j a va 2 s .c o m 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. 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)); } }
From source file:com.Candy.center.CandyCenter.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.slim_center); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // 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/*w ww . ja va2 s . co m*/ 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. 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)); } }
From source file:org.ounl.lifelonglearninghub.nfcecology.swipe.SwipeActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_swipe); // 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.setHomeButtonEnabled(true); // 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// w w w .j ava 2 s. c om 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)); } }
From source file:com.wbrenna.gtfsoffline.MainActivity.java
@Override protected void onResume() { super.onResume(); //we want to refresh the databases list Set<String> emptyString = new HashSet<String>(); emptyString.clear();// ww w.j a v a2s. co m Set<String> initial_preferences = mPrefs.getStringSet(getString(R.string.pref_dbs), emptyString); //in case we're on a low-ram system and things aren't cached try { if (!initial_preferences.equals(mDBListPrefsOld)) { mDBListPrefsOld = initial_preferences; //this is the list of currently checked databases mDBActive = null; //just to nullify the previous one. if (initial_preferences.size() != 0) { String[] tmpDBActive = initial_preferences.toArray(new String[initial_preferences.size()]); dbHelper.gatherFiles(); mDBList = dbHelper.GetListofDB(); List<String> workingDBList = new ArrayList<String>(); for (int i = 0; i < tmpDBActive.length; i++) { if (mDBList.contains(tmpDBActive[i])) { workingDBList.add(tmpDBActive[i]); } } if (workingDBList.size() == 0) { mDBActive = null; } else { mDBActive = workingDBList.toArray(new String[workingDBList.size()]); } } mSectionsPagerAdapter.notifyDataSetChanged(); //totally kill the viewPager and all, and recreate! //mSectionsPagerAdapter = null; //getFragmentManager().beginTransaction().replace(containerViewId, fragment); //and create the appropriate tabs final ActionBar actionBar = getActionBar(); /**mSectionsPagerAdapter = new SectionsPagerAdapter( getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager .setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } });**/ if (actionBar != null) { actionBar.removeAllTabs(); } for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); //update the fragment contents /**if (i > 0 ) { Fragment newFragment = new DBListFragment(); Bundle args = new Bundle(); args.putString(DBListFragment.DATABASE, mDBActive[i-1]); newFragment.setArguments(args); getFragmentManager().beginTransaction().replace(i, newFragment); }**/ if (i > 0) { DBListFragment aFragment = (DBListFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":" + Integer.toString(i)); if (aFragment != null) { getSupportFragmentManager().beginTransaction().remove(aFragment).commit(); mSectionsPagerAdapter.notifyDataSetChanged(); //if (aFragment.getView() != null) { //aFragment.updateDisplay(); //} } } else if (i == 0) { FavSectionFragment aFavFragment = (FavSectionFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":" + Integer.toString(i)); if (aFavFragment != null) { //getSupportFragmentManager().beginTransaction().remove(aFavFragment).commit(); //mSectionsPagerAdapter.notifyDataSetChanged(); //if (aFavFragment.getView() != null) { //aFavFragment.updateDisplay(); //} aFavFragment.updatePositions(); } } } } } finally { //restart location manager //mLocationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE); mLocationHelper.refresh(locationListener); } }
From source file:com.shinobicontrols.transitions.StoryDetailActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_story_detail); if (savedInstanceState == null) { // Load the data from the intent on first pass Intent intent = getIntent();//w w w . j av a 2s . c om String story_id = intent.getStringExtra(ARG_STORY_ID); mItem = StoryContent.STORY_MAP.get(story_id); } // Get hold of some relevant content final ViewGroup container = (ViewGroup) findViewById(R.id.container); // What are the layouts we should be able to transition between List<Integer> sceneLayouts = Arrays.asList(R.layout.content_scene_00, R.layout.content_scene_01, R.layout.content_scene_02); // Create the scenes sceneList = new ArrayList<Scene>(); for (int layout : sceneLayouts) { // Create the scene Scene scene = Scene.getSceneForLayout(container, layout, this); // Just before the transition starts, ensure that the content has been loaded scene.setEnterAction(new Runnable() { @Override public void run() { addContentToViewGroup(container); } }); // Save the scene into sceneList.add(scene); } // Build the transition manager TransitionInflater transitionInflater = TransitionInflater.from(this); mTransitionManager = transitionInflater.inflateTransitionManager(R.transition.story_transition_manager, container); // Show the Up button in the action bar. final ActionBar actionBar = getActionBar(); if (actionBar != null) { actionBar.setDisplayHomeAsUpEnabled(true); // Specify we want some tabs actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a listener to cope with tab changes ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { // If there's a scene for this tab index, then transition to it if (tab.getPosition() <= sceneList.size()) { performTransitionToScene(sceneList.get(tab.getPosition())); } } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { // Can ignore this event } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { // Can ignore this event } private void performTransitionToScene(Scene scene) { mTransitionManager.transitionTo(scene); } }; // Add some tabs for (int i = 0; i < sceneList.size(); i++) { actionBar.addTab(actionBar.newTab().setText("Scene " + i).setTabListener(tabListener)); } } // Load the first scene sceneList.get(0).enter(); }
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 www .j a v a 2s. c o 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:au.com.runecasters.volumescheduler.app.RuleActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_rule); mButtonCreateRule = (Button) findViewById(R.id.buttonCreateRule); mSchedulerRule = getIntent().getParcelableExtra("existingRule"); if (mSchedulerRule == null) { mSchedulerRule = new SchedulerRule(getIntent().getIntExtra("selector", -1)); mNewRule = true;/*from w ww . j a v a 2s. c o m*/ } // 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 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); } }); // 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)); } mButtonCreateRule.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) { ScheduleRuleSetter ruleFragment = (ScheduleRuleSetter) mSectionsPagerAdapter.getItem(i); ruleFragment.setRules(mSchedulerRule); } DatabaseHelper dbHelper = DatabaseHelper.getInstance(RuleActivity.this); if (mNewRule) { dbHelper.addRule(mSchedulerRule); } else { dbHelper.updateRule(mSchedulerRule); } setResult(RESULT_OK); finish(); } }); }
From source file:com.norman0406.slimgress.ActivityOps.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_ops); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // 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//w w w .j a v a2 s. c o m 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. 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)); } }
From source file:com.intel.internal.telephony.mdmclitest.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.setContentView(R.layout.main); // Create the adapter that will return a fragment for each // primary sections of the app. like 'Modem Management BASIC OPS' operationTitleAdapter = new OperationTitleAdapter(super.getSupportFragmentManager(), this); // Set up the action bar. final ActionBar actionBar = super.getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager with the sections adapter. this.viewPager = (ViewPager) super.findViewById(R.id.pager); if (this.viewPager == null) { return;/*from www .ja v a 2 s . c om*/ } String[] tabInfo = new String[0]; if (isDSDA) { tabInfo = getResources().getStringArray(R.array.tab_name); } else { viewPager.removeView(findViewById(R.id.pagertab)); } pageComponentList = new ArrayList<PageComponent>(); // Now we have two Action Bars: OperationTitle & SectionsPager // Delete the Page change listener of OperationTitle, // the swaping of SectionsPager only will be enabled. // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < operationTitleAdapter.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. CharSequence pageTitleName = operationTitleAdapter.getPageTitle(i); pageComponentList.add(new PageComponent(pageTitleName, new SectionsPagerAdapter(super.getSupportFragmentManager(), tabInfo))); actionBar.addTab(actionBar.newTab().setText(pageTitleName).setTabListener(this)); } PageComponent firstPage = pageComponentList.get(0); if ((null != firstPage)) { this.viewPager.setAdapter(firstPage.getFragmentPagerAdapter()); } }
From source file:com.hardcopy.blechat.MainActivity.java
/***************************************************** * Overrided methods//from www . j av a 2 s .c om ******************************************************/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //----- System, Context mContext = this; //.getApplicationContext(); mActivityHandler = new ActivityHandler(); AppSettings.initializeAppSettings(mContext); setContentView(R.layout.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(); }