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.coinprism.wallet.WalletOverview.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_wallet_overview); // Initialization viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar();//from w w w . j a v a 2 s. c o m final TabsPagerAdapter tabsPagerAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(tabsPagerAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); String[] tabs = new String[] { getResources().getString(R.string.tab_send), getResources().getString(R.string.tab_wallet), getResources().getString(R.string.tab_transactions) }; // Adding Tabs for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name).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) { } }); viewPager.setCurrentItem(1); }
From source file:com.matze5800.paupdater.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Set View// w ww . ja v a 2 s . c o m setContentView(R.layout.activity_main); context = this; // Get SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); // ActionBar / PagerAdapter mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getFragmentManager()); 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)); } // Finishes Activity if device is not supported device = Functions.detectDevice(context); if (device.equals("unsupported")) { finish(); } }
From source file:com.kosbrother.houseprice.ActionBarTabs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.action_bar_tabs); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // actionBar.setDisplayShowTitleEnabled(false); if (Build.VERSION.SDK_INT >= 14) { actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); }/*from w w w .ja v a2 s. c o m*/ actionBar.addTab(actionBar.newTab().setText("") .setTabListener(new TabListener("http://m.yungching.com.tw/", "YungChing"))); actionBar.addTab(actionBar.newTab().setText("") .setTabListener(new TabListener("http://m.sinyi.com.tw/", "SinYi"))); actionBar.addTab(actionBar.newTab().setText("591") .setTabListener(new TabListener("http://m.591.com.tw/mobile-index.html?f=app", "591"))); CallAds(); }
From source file:ch.ethz.twimight.activities.UserListActivity.java
/** * Called when the activity is first created. *//*from w w w .j a va2 s . c om*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(null); setContentView(R.layout.main); // action bar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mFragments.add(new FriendsFragment()); mFragments.add(new FollowersFragment()); mFragments.add(new PeersFragment()); FragmentPagerAdapter pagAdapter = new FragmentListPagerAdapter(getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.viewpager); mViewPager.setAdapter(pagAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages, select the // corresponding tab. getActionBar().setSelectedNavigationItem(position); } }); Tab tab = actionBar.newTab().setText(R.string.friends).setTabListener(new TabListener(mViewPager)); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.followers).setTabListener(new TabListener(mViewPager)); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.peers).setTabListener(new TabListener(mViewPager)); actionBar.addTab(tab); setInitialTab(getIntent()); }
From source file:com.cloudbase.cbhelperdemo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar to show tabs. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // For each of the sections in the app, add a tab to the action bar. actionBar.addTab(actionBar.newTab().setText(R.string.title_section1).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_section2).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_section3).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_section4).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_section5).setTabListener(this)); }
From source file:com.mitchtodd.myweatherapp.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 single instance of weather model to be used by activity and tab fragments. mWeatherModel = new WeatherModel(this); mWeatherModel.addOnGetWeatherStartedListener(onGetWeatherStartedListener); mWeatherModel.addOnGetWeatherFinishedListener(onGetWeatherFinishedListener); mWeatherModel.startWeatherUpdates(); setLastUpdatedText(true);//from w w w .java 2s . co m findViewById(R.id.refreshButton).setOnClickListener(onRefreshButtonClickListener); // create the adapter that will return a fragment for each of the 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); // set up swipe listener 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:edu.ufl.cise.android.MainActivity.java
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(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.//from w ww. ja v a 2s . co m actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayUseLogoEnabled(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); 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)); } }
From source file:ch.ethz.twimight.activities.SearchableActivity.java
/** * Called when the activity is first created. *///w w w . j av a 2 s .co m @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(null); setContentView(R.layout.main); viewPager = (ViewPager) findViewById(R.id.viewpager); Bundle bundle = new Bundle(); bundle.putInt(ListViewPageAdapter.BUNDLE_TYPE, ListViewPageAdapter.BUNDLE_TYPE_SEARCH_RESULTS); pagAdapter = new ListViewPageAdapter(getFragmentManager(), bundle); viewPager.setAdapter(pagAdapter); viewPager.setCurrentItem(actionBar.getSelectedNavigationIndex()); //action bar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages, select the // corresponding tab. getActionBar().setSelectedNavigationItem(position); } }); Tab tab = actionBar.newTab().setText("Tweets").setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); tab = actionBar.newTab().setText("Users").setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); // Get the intent and get the query intent = getIntent(); //processIntent(intent); }
From source file:edu.csh.coursebrowser.AboutActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); // Set up the action bar to show tabs. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // For each of the sections in the app, add a tab to the action bar. actionBar.addTab(actionBar.newTab().setText("About").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("License").setTabListener(this)); this.setTitle("About"); }
From source file:com.amen.browser.ComboViewActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED);//www . ja v a 2s. c o m Bundle extras = getIntent().getExtras(); Bundle args = extras.getBundle(EXTRA_COMBO_ARGS); String svStr = extras.getString(EXTRA_INITIAL_VIEW, null); ComboViews startingView = svStr != null ? ComboViews.valueOf(svStr) : ComboViews.Bookmarks; mViewPager = new ViewPager(this); mViewPager.setId(R.id.tab_view); setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); if (BrowserActivity.isTablet(this)) { bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_USE_LOGO); bar.setHomeButtonEnabled(true); } else { bar.setDisplayOptions(0); } mTabsAdapter = new TabsAdapter(this, mViewPager); /* mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_bookmarks), BrowserBookmarksPage.class, args);*/ mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_history), BrowserHistoryPage.class, args); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_TAB, 0)); } else { switch (startingView) { case Bookmarks: mViewPager.setCurrentItem(0); break; case History: mViewPager.setCurrentItem(1); break; case Snapshots: mViewPager.setCurrentItem(2); break; } } }