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:com.scto.filerenamer.FileRenamerActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mSettings = Prefs.getSharedPreferences(this); mSettings.registerOnSharedPreferenceChangeListener(this); if (Prefs.getThemeType(this) == false) { mThemeId = R.style.AppTheme_Light; setTheme(mThemeId);//from ww w.j a va 2 s. co m } else { mThemeId = R.style.AppTheme_Dark; setTheme(mThemeId); } ActionBar mActionBar = getActionBar(); if (mActionBar != null) { mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setDisplayShowHomeEnabled(true); mActionBar.setDisplayShowTitleEnabled(true); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); } else { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "mActionBar == null"); } } setContentView(R.layout.fragment_tabs_pager); mTabHost = (TabHost) findViewById(android.R.id.tabhost); mTabHost.setup(); mViewPager = (ViewPager) findViewById(R.id.pager); mTabsAdapter = new TabsAdapter(this, mTabHost, mViewPager); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.addNumber)).setIndicator(getString(R.string.addNumber)), AddNumbersFragment.class, null); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.addCustom)).setIndicator(getString(R.string.addCustom)), AddCustomFragment.class, null); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.addDate)).setIndicator(getString(R.string.addDate)), AddCharsFragment.class, null); mTabsAdapter.addTab(mTabHost.newTabSpec(getString(R.string.findAndReplace)) .setIndicator(getString(R.string.findAndReplace)), AddDateFragment.class, null); mTabsAdapter.addTab( mTabHost.newTabSpec(getString(R.string.removeChars)).setIndicator(getString(R.string.removeChars)), RemoveCharsFragment.class, null); Bundle extras = getIntent().getExtras(); if (extras != null) { this.setTitle(extras.getString("dir") + " :: " + getString(R.string.app_name)); } else { if (BuildConfig.DEBUG) { Log.w("[" + TAG + "]", "onCreate( savedInstanceState ) : extras == null"); } this.setTitle(" :: " + getString(R.string.app_name)); } if (savedInstanceState != null) { mActionBar.setSelectedNavigationItem(savedInstanceState.getInt("action_bar_tab", 0)); mTabHost.setCurrentTabByTag(savedInstanceState.getString("tab_host")); } }
From source file:org.ado.minesync.gui.MineSyncMainActivity.java
/** * Called when the activity is first created. * * @param savedInstanceState If the activity is being re-initialized after * previously being shut down then this Bundle contains the data it most * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b> */// ww w. j a va2s .co m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ALog.d(TAG, "onCreate. savedInstanceState [" + savedInstanceState + "]."); setContentView(R.layout.activity_main); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getApplicationContext(), getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); 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); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } accountManager = getDropboxAccountManager(getApplicationContext()); activityTracker = new ActivityTracker(getApplicationContext()); minecraftDropboxStatus = new MinecraftDropboxStatus(this); upgradeManager = new UpgradeManager(getApplicationContext()); upgradeManager.upgradeIfNeeded(); startServicesIfNeeded(); ALog.d(TAG, "var configProcessActive [" + configProcessActive + "]"); }
From source file:com.manoj.macawplayer.SwipeViewActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(R.drawable.theme_skyblue);/*from w ww.j a v a 2 s. c o m*/ requestWindowFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.swipe_view); int actionBarTitleId = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); TextView actionBarTextView = (TextView) findViewById(actionBarTitleId); if (actionBarTextView != null) { Log.i("actionBarTextView :", "not null"); actionBarTextView.setTextColor(Color.GREEN); } else Log.i("actionBarTextView :", "null"); // 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(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //to remove the title and icon above the action bar getActionBar().setDisplayShowTitleEnabled(false); getActionBar().setDisplayShowHomeEnabled(false); // 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); LinearLayout homeScreen = (LinearLayout) findViewById(R.id.swipeviewl); utilities = new Utilities(); utilities.colorSeter(homeScreen, getApplicationContext()); 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)).setTabListener(this)); /*Tab tab = actionBar.getTabAt(i); View v = tab.setgetCustomView(); v.setBackgroundResource(R.drawable.theme_skyblue);*/ } }
From source file:com.hmdone.serialbluetooth.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); 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 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//from w ww. ja va 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++) { // 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:br.com.GUI.perfil.HomePersonal.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home_personal); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); pref = getApplicationContext().getSharedPreferences("MyPref", 0); editor = pref.edit();/*from w w w. ja v a2 s. c om*/ b = new Banco(this, null, null, 0); // Initilization Log.i("usuario", pref.getString("usuario", null)); Log.i("tipo", pref.getString("tipo", null)); viewPager = (ViewPager) findViewById(R.id.pagerHomePersonal); viewPager.setOffscreenPageLimit(5); actionBar = getActionBar(); mAdapter = new TabsPagerAdapterHomePersonal(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Adding Tabs actionBar.addTab(actionBar.newTab().setIcon(R.drawable.icon_alunos_tab).setTabListener(this)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.icon_agenda_tab).setTabListener(this)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.icon_treinamentos_tab).setTabListener(this)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.icon_perfil_tab).setTabListener(this)); /** * on swiping the viewpager make respective tab selected * */ viewPager.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) { } }); //Starta O servio Intent i = new Intent(this, WorkUpService.class); startService(i); }
From source file:com.baker.david.irishwhalespotting.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.setUpNavigationDrawer(); // 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. this.actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); Bundle b = getIntent().getExtras();/*w ww . ja va 2 s . co m*/ MainActivity.webAccess = b.getBoolean(Constants.WEB_ACCESS); MainActivity.preSelectedTabId = b.getInt(Constants.TAB_ID); // 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 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)); } mViewPager.setCurrentItem(preSelectedTabId); if (!webAccess) { mViewPager.setCurrentItem(5); } }
From source file:ca.cs.ualberta.localpost.view.MainActivity.java
@SuppressLint("NewApi") @Override//from w w w .j a v a 2 s .com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Loads existing user or creates a new one try { standardUser = Serialize.loaduser(getApplicationContext()); } catch (Exception e) { e.printStackTrace(); } ConnectivityCheck conn = new ConnectivityCheck(this); if (conn.isConnectingToInternet()) { // Set the users default location GPSLocation gpsLocation = new GPSLocation(getApplicationContext()); Address address = gpsLocation.getAddress(); standardUser.setAddress(address); } // Save users current location in file Serialize.SaveUser(standardUser, getApplicationContext()); /** Generate The Tab Views */ viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar(); mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (String tab : tabs) { actionBar.addTab(actionBar.newTab().setText(tab).setTabListener(this)); } viewPager.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: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 www . j av 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++) { 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.hardcopy.retrowatch.RetroWatchActivity.java
/***************************************************** * // w w w . jav a 2 s. com * Overrided methods * ******************************************************/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //----- System, Context mContext = this;//.getApplicationContext(); mActivityHandler = new ActivityHandler(); setContentView(R.layout.activity_retro_watch); // Load static utilities mUtils = new Utils(mContext); // 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 RetroWatchFragmentAdapter(mFragmentManager, mContext, this); // 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(); }
From source file:ca.cmput301f13t03.adventure_datetime.view.BrowseView.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.viewpager);//from w w w.j a v a2 s. c om /* Set up View Pager */ _adapter = new ViewPagerAdapter(getSupportFragmentManager()); _viewPager = (ViewPager) findViewById(R.id.pager); _viewPager.setAdapter(_adapter); /* Set up Tabs */ final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabReselected(Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(Tab tab, FragmentTransaction ft) { _viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(Tab tab, FragmentTransaction ft) { } }; actionBar.addTab(actionBar.newTab().setText("Saved").setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText("My Stories").setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText("Online").setTabListener(tabListener)); /* Change tabs when View Pager swiped */ _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); }