List of usage examples for android.app ActionBar newTab
@Deprecated public abstract Tab newTab();
From source file:com.androiduipatterns.smashingandroidui.examples.tabs.TabsExampleActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_tabs_example); // 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 action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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./*from w ww.java 2s .c o m*/ 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 // listener for when this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.kaow.caltest.UserInfo.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_user_info); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); // Specify that the Home button should show an "Up" caret, indicating that touching the // button will take the user one step up in the application's hierarchy. actionBar.setDisplayHomeAsUpEnabled(true); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/* w w w. ja v a2s . com*/ 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 < uInfoTitles.length; i++) { actionBar.addTab(actionBar.newTab().setText(uInfoTitles[i]).setTabListener(this)); } }
From source file:com.example.administrator.myapplication2._2_exercise._2_End._2_EndMain.java
/***************************************************** * Overrided methods/*from w w w . j a v a2 s. co m*/ ******************************************************/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //----- System, Context mContext = this; //.getApplicationContext(); mActivityHandler = new ActivityHandler(); AppSettings.initializeAppSettings(mContext); setContentView(R.layout._2_end_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)); } }
From source file:ch.bfh.instacircle.NetworkActiveActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_network_active); // 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 action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override//from w ww. j a v a 2s. 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++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } // Handle the change of the Wifi configuration wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); adhoc = new AdhocWifiManager(wifi); wifiapmanager = new WifiAPManager(); registerReceiver(wifiReceiver, new IntentFilter(WifiManager.WIFI_STATE_CHANGED_ACTION)); // Is NFC available on this device? nfcAvailable = this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC); // only set up the NFC stuff if NFC is also available if (nfcAvailable) { nfcAdapter = NfcAdapter.getDefaultAdapter(this); if (nfcAdapter.isEnabled()) { // Setting up a pending intent that is invoked when an NFC tag // is tapped on the back pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); nfcIntentFilter = new IntentFilter(); nfcIntentFilter.addAction(NfcAdapter.ACTION_NDEF_DISCOVERED); nfcIntentFilter.addAction(NfcAdapter.ACTION_TAG_DISCOVERED); intentFiltersArray = new IntentFilter[] { nfcIntentFilter }; } else { nfcAvailable = false; } } }
From source file:com.example.kaow.caltest.MainFrag.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.frag_main);/* w w w. j a v a 2 s . co m*/ // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); // Specify that the Home button should show an "Up" caret, indicating that touching the // button will take the user one step up in the application's hierarchy. actionBar.setDisplayHomeAsUpEnabled(true); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); 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 < mFoodTitles.length || i < mFoodIcon.length; i++) { actionBar.addTab(actionBar.newTab().setIcon(mFoodIcon[i]).setText(mFoodTitles[i]).setTabListener(this)); } }
From source file:com.xortech.sender.SenderMain.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.sender_main); // REMOVE THE TITLE FROM THE ACTIONBAR getActionBar().setDisplayShowTitleEnabled(false); preferences = PreferenceManager.getDefaultSharedPreferences(this); mapType = preferences.getString("mapType", GMAPS); // CHECK FOR "DON'T KEEP ACTIVITIES" IN DEVELOPER OPTIONS boolean checkDeveloper = isAlwaysFinishActivitiesOptionEnabled(); if (checkDeveloper) { showDeveloperOptionsScreen();/*w ww. j ava2 s . c om*/ } /* * IF GOOGLE MAPS IS SELECTED AS THE DEFAULT, THEN CHECK TO * SEE IF THE USER HAS THE CORRECT VERSION OF GOOGLE PLAY SERVICES */ if (mapType.equals(GMAPS)) { // GET GOOGLE PLAY STATUS int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this); // CHECK IF GOOGLE PLAY SERVICE IS AVAILABLE try { if (status != ConnectionResult.SUCCESS) { GooglePlayServicesUtil.getErrorDialog(status, this, RQS_GooglePlayServices).show(); } } catch (Exception e) { Log.e("Error: GooglePlayServiceUtil: ", "" + e); } } // REGISTER A BROADCAST RECEIVER IntentFilter localIntentFilter = new IntentFilter("android.provider.Telephony.SMS_RECEIVED"); localIntentFilter.setPriority(2147483646); mReceiver = new SmsReceiver(); registerReceiver(mReceiver, localIntentFilter); try { // TRY TO LAUNCH APP RATER AppRater.app_launched(this); } catch (Exception e) { Log.e("Error AppRater: ", "" + e); } // 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); 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++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.adbird.MenuTabActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab_menu);// w w w.j a v a 2 s . c o m mContext = this.getApplicationContext(); SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE); String lang = prefs.getString("lang", null); Locale locale = new Locale(lang); Locale.setDefault(locale); Configuration config = new Configuration(); config.locale = locale; getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics()); SpannableString s = new SpannableString(mContext.getResources().getString(R.string.ads_title)); s.setSpan(new TypefaceSpan(this, "GothaProReg.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setTitle(s); actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); SpannableString s = new SpannableString(mAppSectionsPagerAdapter.getPageTitle(position)); s.setSpan(new TypefaceSpan(getApplicationContext(), "GothaProReg.otf"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); actionBar.setTitle(s); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this)); } }
From source file:de.knufficast.ui.main.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); queueFragment = new QueueFragment(); feedsFragment = new FeedsFragment(); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setHomeButtonEnabled(false); // Set up the ViewPager with the sections adapter. viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(sectionsPagerAdapter); // 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./*ww w . j a v a 2s .c o m*/ viewPager.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 < sectionsPagerAdapter.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(sectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.android.tabbedroombookingtimetabledisplay.MainFragmentActivity.java
@SuppressWarnings("deprecation") 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(); tabSettings(actionBar);// w ww . j a va 2 s . c om // 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)) .setIcon(mAppSectionsPagerAdapter.getPageIcon(i)).setTabListener(this)); } if (!isNetworkAvailable()) { createADialog(); } }
From source file:com.xenon.greenup.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent. actionBar.setHomeButtonEnabled(false); //Set the stacked background otherwise we get the gross dark gray color under the icon BitmapDrawable background = (BitmapDrawable) getResources().getDrawable(R.drawable.bottom_menu); background.setTileModeXY(TileMode.REPEAT, TileMode.MIRROR); actionBar.setStackedBackgroundDrawable(background); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setIcon(R.drawable.bottom_menu); _ViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, _ViewPager); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < 3; 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.Tab tabToAdd = actionBar.newTab(); if (i == 0) //Set the home page as active since we'll start there: tabToAdd.setIcon(getActiveIcon(i)); else//from w w w . j a v a2 s . c om tabToAdd.setIcon(getRegularIcon(i)); mTabsAdapter.addTab(tabToAdd); } //Setting the display to custom will push the action bar to the top //which gives us more real estate actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM); actionBar.show(); Log.i("visible", "" + _ViewPager.VISIBLE); }