Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.saigopinarimeti.helloworld.Adapters;
- import android.support.annotation.Nullable;
- import android.support.v4.app.Fragment;
- import android.support.v4.app.FragmentManager;
- import android.support.v4.app.FragmentPagerAdapter;
- import android.support.v4.view.PagerAdapter;
- import com.example.saigopinarimeti.helloworld.fragments.AFragment;
- import com.example.saigopinarimeti.helloworld.fragments.BFragment;
- import com.example.saigopinarimeti.helloworld.fragments.CFragment;
- public class TabViewPagerAdapter extends FragmentPagerAdapter {
- public TabViewPagerAdapter(FragmentManager fm) {
- super(fm);
- }
- @Override
- public Fragment getItem(int position) {
- Fragment fragment = null;
- if (position == 0){
- fragment = new AFragment();
- }
- if (position == 1){
- fragment = new BFragment();
- }
- if (position == 2){
- fragment = new CFragment();
- }
- return fragment;
- }
- @Override
- public int getCount() {
- return 3;
- }
- @Nullable
- @Override
- public CharSequence getPageTitle(int position) {
- String title = "";
- if (position == 0){
- title = "A Tab";
- }
- if (position == 1){
- title = "B Tab";
- }
- if (position == 2){
- title = "C Tab";
- }
- return title;
- }
- }
Add Comment
Please, Sign In to add comment