Search in sources :

Example 6 with SamplePagerAdapter

use of me.relex.circleindicator.sample.SamplePagerAdapter in project CircleIndicator by ongakuer.

the class DynamicAdapterFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    view.findViewById(R.id.add).setOnClickListener(this);
    view.findViewById(R.id.remove).setOnClickListener(this);
    mAdapter = new SamplePagerAdapter(1) {

        @Override
        public int getItemPosition(Object object) {
            return POSITION_NONE;
        }
    };
    ViewPager viewpager = (ViewPager) view.findViewById(R.id.viewpager);
    CircleIndicator indicator = (CircleIndicator) view.findViewById(R.id.indicator);
    viewpager.setAdapter(mAdapter);
    indicator.setViewPager(viewpager);
    mAdapter.registerDataSetObserver(indicator.getDataSetObserver());
}
Also used : CircleIndicator(me.relex.circleindicator.CircleIndicator) ViewPager(android.support.v4.view.ViewPager) SamplePagerAdapter(me.relex.circleindicator.sample.SamplePagerAdapter)

Example 7 with SamplePagerAdapter

use of me.relex.circleindicator.sample.SamplePagerAdapter in project CircleIndicator by ongakuer.

the class ResetAdapterFragment method onViewCreated.

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    mViewpager = (ViewPager) view.findViewById(R.id.viewpager);
    mIndicator = (CircleIndicator) view.findViewById(R.id.indicator);
    mViewpager.setAdapter(new SamplePagerAdapter(5));
    mIndicator.setViewPager(mViewpager);
    view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mViewpager.setAdapter(new SamplePagerAdapter(1 + mRandom.nextInt(5)));
            mIndicator.setViewPager(mViewpager);
        }
    });
}
Also used : View(android.view.View) SamplePagerAdapter(me.relex.circleindicator.sample.SamplePagerAdapter)

Aggregations

SamplePagerAdapter (me.relex.circleindicator.sample.SamplePagerAdapter)7 CircleIndicator (me.relex.circleindicator.CircleIndicator)6 ViewPager (android.support.v4.view.ViewPager)5 View (android.view.View)2 LoopViewPager (com.imbryk.viewPager.LoopViewPager)1