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.ckchan.assignment1.ckchan_todolist.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Initialization of viewPager viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar();/*from w ww . jav a 2 s . co m*/ tabsPagerAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(tabsPagerAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //Adding Tabs for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); } viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { //Execute code in onArticleSelected when tab is selected switch (position) { case 0: //This code was from: //http://stackoverflow.com/questions/20412379/viewpager-update-fragment-on-swipe 2014-09-23 TodoFragment todoFragment = (TodoFragment) tabsPagerAdapter.instantiateItem(viewPager, position); if (todoFragment != null) { todoFragment.onArticleSelected(); } break; case 1: ArchiveFragment archiveFragment = (ArchiveFragment) tabsPagerAdapter.instantiateItem(viewPager, position); if (archiveFragment != null) { archiveFragment.onArticleSelected(); } break; } actionBar.setSelectedNavigationItem(position); //Switch to selected tab } @Override public void onPageScrolled(int arg0, float arg1, int arg2) { } @Override public void onPageScrollStateChanged(int arg0) { } }); }
From source file:com.javierd.about.AboutActivity.java
/** Called when the activity is first created. */ @Override/*from www. j ava 2 s .c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); appContext = getApplicationContext(); ActionBar actionbar = getActionBar(); actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionbar.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.about_tab_title), AboutFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.features_tab_title), FeaturesFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.dirt_tab_title), DirtFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.contributors_tab_title), ContributorsFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.social_tab_title), SocialFragment.class, null); }
From source file:com.eu.lad.JamCamViewer.JamCamViewerMainActivity.java
/** * Called when the activity is first created. *//* ww w .ja v a 2s . c om*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Check that the activity is using the layout version with // the main_fragment_container FrameLayout if (findViewById(R.id.route_pager) != null) { // However, if we're being restored from a previous state, // then remove any saved support fragments to avoid overlapping // the Action bar. if (savedInstanceState != null) { return; } // Initialise the route inventory routeInventory = new LinkedList<Route>(); seedBaseData(); // Set-up the tabs in the Action Bar final ActionBar actionBar = getActionBar(); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Add a tab for each route in the routeInventory for (Route r : routeInventory) { ActionBar.Tab routeTab = actionBar.newTab(); routeTab.setText(r.getRouteLabel()); routeTab.setTabListener(this.getTabListener()); actionBar.addTab(routeTab); } } }
From source file:org.travey.travey.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initilization viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar();//from w ww . j a v a 2 s. com mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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) { } }); Intent i = getIntent(); if (i.getStringExtra("fromNotify") != null) { Log.i("**************", "Setting notification pref to false"); myPrefs = this.getSharedPreferences("myPrefs", MODE_PRIVATE); myPrefsEditor = myPrefs.edit(); myPrefsEditor.putLong("lastTouchTime", new Date().getTime()); myPrefsEditor.putBoolean("isNotified", false); myPrefsEditor.commit(); } if (i.getStringExtra("tab") != null) { viewPager.setCurrentItem(1); } }
From source file:com.aogp.about.AboutActivity.java
/** Called when the activity is first created. */ @Override/* w w w.j a va2s.c o m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); appContext = getApplicationContext(); ActionBar actionbar = getActionBar(); actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionbar.setDisplayShowHomeEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.about_tab_title), AboutFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.features_tab_title), FeaturesFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.aogp_tab_title), AOGPFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.contributors_tab_title), ContributorsFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.testers_tab_title), TestersFragment.class, null); mTabsAdapter.addTab(actionbar.newTab().setText(R.string.social_tab_title), SocialFragment.class, null); }
From source file:fm.krui.kruifm.DJInfoActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dj_info_container_layout); showLoadingScreen(true);//w w w. java2s .c o m // Allow custom home button actions ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); /* For each component, create a tab for navigation */ // Stream ActionBar.Tab bioTab = actionBar.newTab().setText(getResources().getString(R.string.dj_bio_tab)) .setTabListener(this); // Extended Playlist ActionBar.Tab twitterTab = actionBar.newTab().setText(getResources().getString(R.string.dj_twitter_tab)) .setTabListener(this); // Then apply the tabs to the ActionBar. actionBar.addTab(bioTab); actionBar.addTab(twitterTab); // Download DJ object attached to the last played song to display information. Log.v(TAG, "Grabbing DJ information..."); DJInfoFetcher fetcher = new DJInfoFetcher(this, this); fetcher.execute(); }
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 ava 2s . 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.smbc2.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 w w .j ava2 s . c o m*/ actionBar.setHomeButtonEnabled(false); // 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)); } }
From source file:org.aminb.mathtools.app.activity.ContentActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_content); titleId = getIntent().getExtras().getInt(ARG_TITLE_ID); titles = getIntent().getExtras().getStringArray(ARG_TITLES); mActionBar.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/* www. j a v a 2 s .c om*/ public void onPageSelected(int position) { mActionBar.setSelectedNavigationItem(position); // mActionBar.setSubtitle(titles[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. mActionBar.addTab( mActionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } mActionBar.setTitle(titleId); // mActionBar.setSubtitle(titles[0]); // getActionbarSubtitle().setTextColor(getResources().getColor(R.color.actionbar_subtitle_text_color)); }
From source file:semanticweb.hws14.movapp.activities.Criteria.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); setContentView(R.layout.activity_criteria); that = this;/* w w w. ja v a 2s . com*/ initCriteriaView(); //Get the Tabpager criteriaPagerAdapter = new CriteriaPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(criteriaPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a tab listener that is called when the user changes tabs. ActionBar.TabListener tabListener = new ActionBar.TabListener() { public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { mViewPager.setCurrentItem(tab.getPosition()); tabPosition = tab.getPosition(); } public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { // hide the given tab } public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { // probably ignore this event } }; //add the two tabs actionBar.addTab(actionBar.newTab().setText("Movies").setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setText("Actors").setTabListener(tabListener)); }