use of in.srain.cube.views.pager.TabPageIndicator in project android-Ultra-Pull-To-Refresh by liaohuqiu.
the class ViewPagerActivity method initCateViews.
private void initCateViews() {
int startIndex = 0;
mCatTabPageIndicator = (TabPageIndicator) findViewById(R.id.view_pager_tab_indicator);
mFragmentViewPager = (ViewPager) this.findViewById(R.id.view_pager_view_pager);
ArrayList<ViewPagerFragment> list = new ArrayList<ViewPagerFragment>();
for (int i = 1; i <= 8; i++) {
list.add(ViewPagerFragment.create(i));
}
mPagerAdapter = new FragmentViewPagerAdapter(getSupportFragmentManager(), list);
mFragmentViewPager.setAdapter(mPagerAdapter);
mCatTabPageIndicator.setViewHolderCreator(new TabPageIndicator.ViewHolderCreator() {
@Override
public TabPageIndicator.ViewHolderBase createViewHolder() {
return new HomeCatItemViewHolder();
}
});
mCatTabPageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int i) {
switchTo(i);
}
});
mCatTabPageIndicator.setViewPager(mFragmentViewPager);
mPtrFrame = (PtrClassicFrameLayout) findViewById(R.id.view_pager_ptr_frame);
mPtrFrame.disableWhenHorizontalMove(true);
mPtrFrame.setPtrHandler(new PtrHandler() {
@Override
public boolean checkCanDoRefresh(PtrFrameLayout frame, View content, View header) {
return mPagerAdapter.checkCanDoRefresh();
}
@Override
public void onRefreshBegin(PtrFrameLayout frame) {
mPagerAdapter.updateData();
}
});
mFragmentViewPager.setCurrentItem(startIndex);
}
Aggregations