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:net.forkk.autocron.EditAutomationActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();//from ww w .jav a2 s.c o m assert intent != null; mAutomationPointer = (ComponentPointer) intent.getSerializableExtra(EXTRA_AUTOMATION_POINTER); mShowTriggerList = mAutomationPointer instanceof Event.Pointer; setContentView(R.layout.activity_edit_automation); // 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. mPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mPagerAdapter); // 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 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 < mPagerAdapter.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(mPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.android.contactslist.ui.ContactsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { Utils.enableStrictMode();//ww w . ja va 2 s .com } super.onCreate(savedInstanceState); // Set main content view. On smaller screen devices this is a single pane view with one // fragment. One larger screen devices this is a two pane view with two fragments. setContentView(R.layout.activity_main); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab(actionBar.newTab().setText(R.string.people).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.call_history).setTabListener(this)); // Check if two pane bool is set based on resource directories isTwoPaneLayout = getResources().getBoolean(R.bool.has_two_panes); if (isTwoPaneLayout) { // If two pane layout, locate the contact detail fragment mContactDetailFragment = (ContactDetailFragment) getSupportFragmentManager() .findFragmentById(R.id.contact_detail); } }
From source file:org.aakashlabs.arthashastra.Novice_Activity.java
/** Called when the activity is first created. */ @Override// w ww . j ava2 s. c om public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_novice); //ActionBar gets initiated ActionBar actionbar = getActionBar(); //Tell the ActionBar we want to use Tabs. actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //initiating both tabs and set text to it. ActionBar.Tab Part1NTab = actionbar.newTab().setText("Part 1"); ActionBar.Tab Part2NTab = actionbar.newTab().setText("Part 2"); ActionBar.Tab Part3NTab = actionbar.newTab().setText("Part 3"); //create the two fragments we want to use for display content // these are two objects of the fragment classes (yet to be made) Fragment Part1NFragment = new Part1N(); Fragment Part2NFragment = new Part2N(); Fragment Part3NFragment = new Part3N(); //set the Tab listener. Now we can listen for clicks. Part1NTab.setTabListener(new MyTabsListener(Part1NFragment)); Part2NTab.setTabListener(new MyTabsListener(Part2NFragment)); Part3NTab.setTabListener(new MyTabsListener(Part3NFragment)); //add the two tabs to the action bar actionbar.addTab(Part1NTab); actionbar.addTab(Part2NTab); actionbar.addTab(Part3NTab); }
From source file:com.example.marijaradisavljevic.bla.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main_marija); // 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 a va2 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:com.android.projectesang.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.// w w w .j a va 2s . com 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:com.example.android.scrolltricks.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); PagerAdapter adapter = new FragmentStatePagerAdapter(getSupportFragmentManager()) { @Override/*from ww w.j a va2 s . c om*/ public Fragment getItem(int position) { switch (position) { case 0: return new QuickReturnFragment(); case 1: return new StickyFragment(); } return null; } @Override public int getCount() { return 2; } @Override public CharSequence getPageTitle(int position) { switch (position) { case 0: return getString(R.string.quick_return_item); case 1: return getString(R.string.sticky_item); } return null; } }; mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(adapter); mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); mPager.setPageMargin(getResources().getDimensionPixelSize(R.dimen.page_margin)); getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (int position = 0; position < adapter.getCount(); position++) { getActionBar() .addTab(getActionBar().newTab().setText(adapter.getPageTitle(position)).setTabListener(this)); } getActionBar().setDisplayShowHomeEnabled(false); getActionBar().setDisplayShowTitleEnabled(false); }
From source file:com.stockbrowser.ComboViewActivity.java
@TargetApi(14) @Override//from www . j a va2 s . com protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setResult(RESULT_CANCELED); Bundle extras = getIntent().getExtras(); Bundle args = extras.getBundle(EXTRA_COMBO_ARGS); // // String svStr = extras.getString(EXTRA_INITIAL_VIEW, null); String svStr = extras.getString(EXTRA_INITIAL_VIEW); UI.ComboViews startingView = svStr != null ? UI.ComboViews.valueOf(svStr) : UI.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); 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; } } }
From source file:com.afollestad.overhear.ui.OverviewScreen.java
/** * Sets up the action bar tabs and the view pager. */// ww w. j a v a 2s . c om private void setupTabs() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(5); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); ActionBar.TabListener mTabListener = new ActionBar.TabListener() { @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { invalidateOptionsMenu(); mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { Fragment frag = getFragmentManager().findFragmentByTag("page:" + tab.getPosition()); if (frag instanceof ListFragment) { if (frag.getView() != null) ((ListFragment) frag).getListView().setSelection(0); } else if (frag instanceof OverhearGridFragment) { if (frag.getView() != null) ((OverhearGridFragment) frag).getListView().setSelection(0); } } }; for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) actionBar.addTab( actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(mTabListener)); actionBar.setSelectedNavigationItem(Store.i(this, "focused_tab", 2)); }
From source file:com.agilemessage.ameffectivenavigation.MainActivity.java
@Override 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./* www.j av a 2s . c o m*/ actionBar.setHomeButtonEnabled(true); // 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); // Toast.makeText(getApplicationContext(), "onPageSelected, pos=" + position, // Toast.LENGTH_SHORT).show(); } }); // // 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)); // } actionBar.addTab(actionBar.newTab().setText("about").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("share").setTabListener(this)); actionBar.addTab(actionBar.newTab().setText("go").setTabListener(this)); }
From source file:org.aakashlabs.arthashastra.Advanced_Activity.java
/** Called when the activity is first created. */ @Override/*from ww w . jav a2s . c om*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_advanced); //ActionBar gets initiated ActionBar actionbar = getActionBar(); //Tell the ActionBar we want to use Tabs. actionbar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); //initiating both tabs and set text to it. ActionBar.Tab Part1ATab = actionbar.newTab().setText("Part 1"); ActionBar.Tab Part2ATab = actionbar.newTab().setText("Part 2"); // ActionBar.Tab Part3ATab = actionbar.newTab().setText("Part 3"); //create the two fragments we want to use for display content // these are two objects of the fragment classes (yet to be made) Fragment Part1AFragment = new Part1A(); Fragment Part2AFragment = new Part2A(); // Fragment Part3AFragment= new Part3A(); //set the Tab listener. Now we can listen for clicks. Part1ATab.setTabListener(new MyTabsListener3(Part1AFragment)); Part2ATab.setTabListener(new MyTabsListener3(Part2AFragment)); // Part3ATab.setTabListener(new MyTabsListener3(Part3AFragment)); //add the two tabs to the action bar actionbar.addTab(Part1ATab); actionbar.addTab(Part2ATab); // actionbar.addTab(Part3ATab); }