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.geenk.fileexplorer.FileExplorerTabActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.fragment_pager); mViewPager = (ViewPager) findViewById(R.id.pager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME); mTabsAdapter = new TabsAdapter(this, mViewPager); // mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), // FileViewActivity.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote), ServerControlActivity.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(INSTANCESTATE_TAB, 0)); }// w w w . ja v a2 s .co m }
From source file:com.Candy.ota.settings.About.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about);//from w ww .ja v a 2 s .c o m mHomeURL = (TextView) findViewById(ID_HOME_URL); mContact = (TextView) findViewById(ID_CONTACT); mLicense = (TextView) findViewById(ID_LICENSE); mHomeURL.setMovementMethod(LinkMovementMethod.getInstance()); mContact.setMovementMethod(LinkMovementMethod.getInstance()); mLicense.setMovementMethod(LinkMovementMethod.getInstance()); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); }
From source file:net.cherryzhang.sekuhara.LoginAndRegistration.LoginAndRegistrationActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_swipe_view_login_and_registration); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); Parse.initialize(this, "TsVbzF7jXzY1C0o86V2xxAxgSxvy4jmbyykOabPl", "VzamwWm4WswbDFxrxos2oSerQ2Av4RM6J5mNnNgr"); final ActionBar actionBar = getActionBar(); actionBar.hide();//ww w. j a v a2 s. c o m actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); ViewPager.SimpleOnPageChangeListener mPageChangeListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }; pageIndicator = (CirclePageIndicator) findViewById(R.id.CPI_pageIndicator); pageIndicator.setViewPager(mViewPager); pageIndicator.setOnPageChangeListener(mPageChangeListener); pageIndicator.setCurrentItem(0); //TODO: make circle page indicator look better final float density = getResources().getDisplayMetrics().density; pageIndicator.setRadius(6 * density); pageIndicator.setPageColor(0xFFFFCCFF); pageIndicator.setFillColor(0xFFFF6699); pageIndicator.setStrokeColor(0xFF000000); pageIndicator.setStrokeWidth(1); // 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.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//from w w w. j a va2 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:in.ac.iitb.intulearn.DetailsActivity.java
/** * Initialise the fragments to be paged/*from ww w .j av a 2s.c om*/ */ private void initialisePaging() { // Set up the action bar. ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Show the Up button in the action bar. actionBar.setDisplayHomeAsUpEnabled(true); // REF: http://android-er.blogspot.in/2012/06/create-actionbar-in-tab-navigation-mode.html actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_description) .setTabListener(new CustomTabListener(this, DescriptionFragment.class.getName()))); actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_experiment) .setTabListener(new CustomTabListener(this, ExperimentFragment.class.getName()))); actionBar.addTab(actionBar.newTab().setText(R.string.title_fragment_evaluate) .setTabListener(new CustomTabListener(this, EvaluateFragment.class.getName()))); }
From source file:com.prolificcoder.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(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//from ww w . j a v a 2 s .c om 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 < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:net.forkk.autocron.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(); assert actionBar != null; 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(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. jav a 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.g_node.gca.abstracts.AbstractContent.java
@Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setContentView(R.layout.activity_abstractcontent_viewpager); Bundle getData = getIntent().getExtras(); value = getData.getString("value"); // Initilization viewPager = (ViewPager) findViewById(R.id.pager); actionBar = getActionBar();/* w w w. j a v a 2 s .c o m*/ mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); mAdapter.setValue(value); //set current UUID for fragments viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true); 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) { } }); }
From source file:com.tesfayeabel.lolchat.ui.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_lolchat_main); viewPager = (ViewPager) findViewById(R.id.pager); final ActionBar actionBar = getActionBar(); ArrayList<LOLChatFragment> fragments = new ArrayList<LOLChatFragment>(); fragments.add(new MainFragment()); fragments.add(new ConversationsFragment()); fragments.add(new SummonerSearchFragment()); viewPager.setOffscreenPageLimit(fragments.size() - 1); viewPager.setAdapter(new FragmentPagerAdapter(getFragmentManager(), fragments)); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override/* w w w . j a v a 2s. c om*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); FragmentPagerAdapter adapter = (FragmentPagerAdapter) viewPager.getAdapter(); if (getLolChat() != null) adapter.getRegisteredFragment(position).onChatConnected(getLolChat()); } @Override public void onPageScrolled(int i, float f, int f1) { } @Override public void onPageScrollStateChanged(int i) { } }); ActionBar.TabListener tl = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { viewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { } }; actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_friend).setTabListener(tl)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_recent).setTabListener(tl)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_search).setTabListener(tl)); }
From source file:de.grobox.liberario.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mViewPager = (ViewPager) findViewById(R.id.pager); final ActionBar actionBar = getActionBar(); // Specify that tabs should be displayed in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create a tab listener that is called when the user changes tabs. ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override/*from w w w. j a v a2 s . c o m*/ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { // show the given tab mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { // hide the given tab } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { // probably ignore this event } }; List<String> fragments = new ArrayList<String>(); fragments.add(DirectionsFragment.class.getName()); actionBar.addTab( actionBar.newTab().setIcon(android.R.drawable.ic_menu_directions).setTabListener(tabListener)); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ic_action_star).setTabListener(tabListener)); fragments.add(FavTripsFragment.class.getName()); actionBar.addTab(actionBar.newTab().setIcon(R.drawable.ic_tab_stations).setTabListener(tabListener)); fragments.add(StationsFragment.class.getName()); mainPagerAdapter = new MainPagerAdapter(getSupportFragmentManager(), this, fragments); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between pages, select the corresponding tab. getActionBar().setSelectedNavigationItem(position); } }); mViewPager.setAdapter(mainPagerAdapter); // show Changelog HoloChangeLog cl = new HoloChangeLog(this); if (cl.isFirstRun() && !cl.isFirstRunEver()) { cl.getLogDialog().show(); } }