Search in sources :

Example 6 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project ride-read-android by Ride-Read.

the class LoginActivity method initViewPager.

private void initViewPager() {
    mFragments = new ArrayList<>(2);
    mFragments.add(new LoginFragment());
    mFragments.add(new RegisterFragment());
    FragmentPagerAdapter fpa = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return mFragments.get(position);
        }

        @Override
        public int getCount() {
            return mFragments.size();
        }
    };
    mViewpagerTabView.setAdapter(fpa);
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter)

Example 7 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project RxBus by ViTess.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    findViewById(R.id.main_bt).setOnClickListener(this);
    findViewById(R.id.main_bt_void).setOnClickListener(this);
    findViewById(R.id.main_bt_tag1).setOnClickListener(this);
    findViewById(R.id.main_bt_tag2).setOnClickListener(this);
    findViewById(R.id.main_bt_tag3).setOnClickListener(this);
    vp = (ViewPager) findViewById(R.id.main_vp);
    arrayList.add(f1);
    arrayList.add(f2);
    adapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return arrayList.get(position);
        }

        @Override
        public int getCount() {
            return arrayList.size();
        }
    };
    vp.setAdapter(adapter);
    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.main_fl, f3);
    transaction.commit();
    RxBus.register(this);
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) Fragment(android.support.v4.app.Fragment) SuppressLint(android.annotation.SuppressLint)

Example 8 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project ViewPagerIndicator by JakeWharton.

the class SampleTabsDefault method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_tabs);
    FragmentPagerAdapter adapter = new GoogleMusicAdapter(getSupportFragmentManager());
    ViewPager pager = (ViewPager) findViewById(R.id.pager);
    pager.setAdapter(adapter);
    TabPageIndicator indicator = (TabPageIndicator) findViewById(R.id.indicator);
    indicator.setViewPager(pager);
}
Also used : TabPageIndicator(com.viewpagerindicator.TabPageIndicator) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) ViewPager(android.support.v4.view.ViewPager)

Example 9 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project AndroidDevelop by 7449.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    viewPager = (ViewPager) findViewById(R.id.viewpager);
    RadioGroup radioGroup = (RadioGroup) findViewById(R.id.rg_group);
    imageView = (ImageView) findViewById(R.id.iv_line);
    Display display = getWindow().getWindowManager().getDefaultDisplay();
    DisplayMetrics dm = new DisplayMetrics();
    display.getMetrics(dm);
    ivWidth = (dm.widthPixels / 3);
    viewPager.addOnPageChangeListener(this);
    radioGroup.setOnCheckedChangeListener(this);
    viewPager.setAdapter(new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public Fragment getItem(int position) {
            return ViewPagerFragment.startFragment(position);
        }

        @Override
        public int getCount() {
            return 3;
        }
    });
}
Also used : RadioGroup(android.widget.RadioGroup) FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) DisplayMetrics(android.util.DisplayMetrics) Fragment(android.support.v4.app.Fragment) Display(android.view.Display)

Example 10 with FragmentPagerAdapter

use of android.support.v13.app.FragmentPagerAdapter in project BookReader by JustWayward.

the class SubjectBookListActivity method initDatas.

@Override
public void initDatas() {
    mDatas = Arrays.asList(getResources().getStringArray(R.array.subject_tabs));
    mTabContents = new ArrayList<>();
    mTabContents.add(SubjectFragment.newInstance("", 0));
    mTabContents.add(SubjectFragment.newInstance("", 1));
    mTabContents.add(SubjectFragment.newInstance("", 2));
    mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

        @Override
        public int getCount() {
            return mTabContents.size();
        }

        @Override
        public Fragment getItem(int position) {
            return mTabContents.get(position);
        }
    };
}
Also used : FragmentPagerAdapter(android.support.v4.app.FragmentPagerAdapter) SubjectFragment(com.justwayward.reader.ui.fragment.SubjectFragment) Fragment(android.support.v4.app.Fragment)

Aggregations

FragmentPagerAdapter (android.support.v4.app.FragmentPagerAdapter)29 Fragment (android.support.v4.app.Fragment)20 ViewPager (android.support.v4.view.ViewPager)8 View (android.view.View)5 Intent (android.content.Intent)3 TabLayout (android.support.design.widget.TabLayout)3 TabPageIndicator (com.viewpagerindicator.TabPageIndicator)3 Toolbar (android.support.v7.widget.Toolbar)2 TextView (android.widget.TextView)2 PageIndicator (com.viewpagerindicator.PageIndicator)2 SuppressLint (android.annotation.SuppressLint)1 Fragment (android.app.Fragment)1 FragmentPagerAdapter (android.support.v13.app.FragmentPagerAdapter)1 FragmentStatePagerAdapter (android.support.v4.app.FragmentStatePagerAdapter)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 ListFragment (android.support.v4.app.ListFragment)1 PagerAdapter (android.support.v4.view.PagerAdapter)1 OnPageChangeListener (android.support.v4.view.ViewPager.OnPageChangeListener)1 RecyclerView (android.support.v7.widget.RecyclerView)1 DisplayMetrics (android.util.DisplayMetrics)1