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.example.kyle.weatherforecast.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); viewPager = (ViewPager) findViewById(R.id.pager); FragmentAdapter adapter = new FragmentAdapter(getSupportFragmentManager()); viewPager.setAdapter(adapter);// ww w.ja v a2s. c o m Calendar calendar = Calendar.getInstance(); String weekDay; SimpleDateFormat dayFormat; dayFormat = new SimpleDateFormat("cccc", Locale.getDefault()); // dayFormat = new SimpleDateFormat("c LLL d", Locale.getDefault()); // dayFormat = (SimpleDateFormat) new SimpleDateFormat().getDateInstance(); actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab(actionBar.newTab().setText("Today").setTabListener(this)); for (int i = 1; i < 5; i++) { calendar.add(Calendar.DAY_OF_WEEK, 1); weekDay = dayFormat.format(calendar.getTime()); actionBar.addTab(actionBar.newTab().setText(weekDay).setTabListener(this)); } if (notificationId == 0) { postAlert(0); } viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int i, float v, int i2) { } @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrollStateChanged(int i) { } }); }
From source file:ch.ethz.twimight.activities.ShowUserListActivity.java
/** * Called when the activity is first created. *//*from w w w.j a v a2s.co m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(null); setContentView(R.layout.main); Intent intent = getIntent(); //action bar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); Bundle bundle = new Bundle(); bundle.putInt(ListViewPageAdapter.BUNDLE_TYPE, ListViewPageAdapter.BUNDLE_TYPE_USERS); ListViewPageAdapter pagAdapter = new ListViewPageAdapter(getFragmentManager(), bundle); viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(pagAdapter); 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(R.string.friends).setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.followers).setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); tab = actionBar.newTab().setText(R.string.peers).setTabListener(new TabListener(viewPager)); actionBar.addTab(tab); //actionBar.setSelectedNavigationItem(intent.getIntExtra(USER_FILTER_REQUEST, FRIENDS_KEY)); viewPager.setCurrentItem(intent.getIntExtra(USER_FILTER_REQUEST, 0)); }
From source file:com.hollowsoft.example.fontdroid.view.MainScreen.java
@Override protected void onCreate(final Bundle savedInstance) { super.onCreate(savedInstance); setContentView(R.layout.main_screen); actionBar = getActionBar();//from w w w . jav a 2s. c o m actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); viewPager = (ViewPager) findViewById(R.id.main_screen_menu_view_pager); viewPager.setAdapter(new MenuAdapter(getSupportFragmentManager(), this)); viewPager.setOnPageChangeListener(this); for (final String menu : getResources().getStringArray(R.array.menu)) { actionBar.addTab(actionBar.newTab().setText(menu).setTabListener(this)); } }
From source file:com.yuya.routerecorder.FragmentTabs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); //bar.setDisplayShowCustomEnabled(true); //bar.setDisplayShowTitleEnabled(false); //bar.setDisplayShowHomeEnabled(false); bar.setDisplayShowCustomEnabled(false); bar.addTab(bar.newTab().setIcon(R.drawable.world_white) .setTabListener(new TabListener<RouteMapFragment>(this, "Show Map", RouteMapFragment.class))); bar.addTab(bar.newTab().setIcon(R.drawable.pen_white_frame) .setTabListener(new TabListener<AddRouteFragment>(this, "Add Trip", AddRouteFragment.class))); bar.addTab(bar.newTab().setIcon(R.drawable.list_new) .setTabListener(new TabListener<MyListFragment>(this, "Show List", MyListFragment.class))); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); }// ww w . j a v a 2 s .co m //FragmentManager manager = getSupportFragmentManager(); //fragmentA = (RouteMapFragment) manager.findFragmentById(R.id.map); //fragmentB = (AddRouteFragment) manager.findFragmentById(R.id.fragment_container); }
From source file:net.networksaremadeofstring.rhybudd.FirstRunSettings.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first_run_settings); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setTitle(getString(R.string.FirstRunTitle)); actionBar.setSubtitle(getString(R.string.FirstRunSubtitle)); // 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 ww w . ja v a2s .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:com.example.routerecorder.FragmentTabs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); instance = this; final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); //bar.setDisplayShowCustomEnabled(true); //bar.setDisplayShowTitleEnabled(false); //bar.setDisplayShowHomeEnabled(false); bar.setDisplayShowCustomEnabled(false); bar.addTab(bar.newTab().setText("Show Map") .setTabListener(new TabListener<RouteMapFragment>(this, "Show Map", RouteMapFragment.class))); bar.addTab(bar.newTab().setText("Add Trip") .setTabListener(new TabListener<AddRouteFragment>(this, "Add Trip", AddRouteFragment.class))); bar.addTab(bar.newTab().setText("Show List") .setTabListener(new TabListener<MyListFragment>(this, "Show List", MyListFragment.class))); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); }/*from w w w . ja v a 2s.co m*/ //FragmentManager manager = getSupportFragmentManager(); //fragmentA = (RouteMapFragment) manager.findFragmentById(R.id.map); //fragmentB = (AddRouteFragment) manager.findFragmentById(R.id.fragment_container); }
From source file:com.android.photos.GalleryActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mMultiChoiceManager = new MultiChoiceManager(this); mViewPager = new ViewPager(this); mViewPager.setId(R.id.viewpager);//from w w w .java 2 s . c o m setContentView(mViewPager); ActionBar ab = getActionBar(); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); ab.setDisplayShowHomeEnabled(false); ab.setDisplayShowTitleEnabled(false); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(ab.newTab().setText(R.string.tab_photos), PhotoSetFragment.class, null); mTabsAdapter.addTab(ab.newTab().setText(R.string.tab_albums), AlbumSetFragment.class, null); if (savedInstanceState != null) { ab.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } }
From source file:com.p1creations.bas1ksBeta.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();// w w w . j av a 2 s. c o m 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) { } }); viewPager.setCurrentItem(1, false); }
From source file:com.mstoyanov.music_lessons.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from ww w . j a v a 2s.c o m final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // if returning from an activity: if (getIntent().getStringExtra("WEEKDAY") != null) { weekday = getIntent().getStringExtra("WEEKDAY"); } if (getIntent().getIntExtra("SELECTED_TAB", 0) != 0) { selectedTab = getIntent().getIntExtra("SELECTED_TAB", 0); } mViewPager = (ViewPager) findViewById(R.id.pager); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (position == 6) { section = position; // "Students" tab actionBar.setSelectedNavigationItem(1); } else if (position == 7) { section = position; // "Add Student" tab actionBar.setSelectedNavigationItem(2); } else { section = position; // a schedule tab actionBar.setSelectedNavigationItem(0); } } }); // Add tabs to the action bar: for (int i = 0; i < 3; i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } actionBar.selectTab(actionBar.getTabAt(selectedTab)); }
From source file:com.little.ibooks.file.FileExplorerTabActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.file_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 ww. ja v a 2 s . c o m // ?"WIFI" Intent intent = getIntent(); if (intent != null) { String fileMode = intent.getStringExtra("mode"); if (fileMode != null && "wifi".equals(fileMode)) { mViewPager.setCurrentItem(1); } } }