Android Open Source - android-viewpager-indicator Sample Fragment Pager Adapter






From Project

Back to project page android-viewpager-indicator.

License

The source code is released under:

MIT License

If you think the Android project android-viewpager-indicator listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.caiying.indicator.demo;
//  www .j  a v  a 2s. c  o m
import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import me.caiying.indicator.R;

public class SampleFragmentPagerAdapter extends FragmentPagerAdapter {
    private static final String[] CONTENT = new String[] {
        "A", "B", "C", "D"
    };
    
    private Context mContext;
    public SampleFragmentPagerAdapter(Context context, FragmentManager fm) {
        super(fm);
        this.mContext = context;
    }

    @Override
    public Fragment getItem(int position) {
        return SampleFragment.newInstance(CONTENT[position % CONTENT.length]);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return new String[]{mContext.getString(R.string.tab1_text), mContext.getString(R.string.tab2_text),
                mContext.getString(R.string.tab3_text), mContext.getString(R.string.tab4_text)}[position];
    }

    @Override
    public int getCount() {
        return CONTENT.length;
    }
}




Java Source Code List

me.caiying.indicator.FadeTabIndicator.java
me.caiying.indicator.LineTabIndicator.java
me.caiying.indicator.demo.ApiDemos.java
me.caiying.indicator.demo.FadeTabActivity.java
me.caiying.indicator.demo.LineTabActivity.java
me.caiying.indicator.demo.SampleFragmentPagerAdapter.java
me.caiying.indicator.demo.SampleFragment.java