private void initViewPager(ShopList shopList) {
if (shopList != null) {
if (!TextUtils.isEmpty(shopList.name)) {
setTitle(shopList.name);
}
List<Label> labels = shopList.sub_labels;
if (labels != null && labels.size() > 0) {
final BaseFragmentPagerAdapter fragmentAdapter = new BaseFragmentPagerAdapter
(getSupportFragmentManager());
for (int i = 0; i < labels.size(); i++) {
Label label = (Label) labels.get(i);
if (i == 0) {
fragmentAdapter.addFragment(ShopCategoryFragment.newInstance(this
.labelId, label.id, shopList), label.name);
} else {
fragmentAdapter.addFragment(ShopCategoryFragment.newInstance(this
.labelId, label.id), label.name);
}
}
this.mViewPager.setAdapter(fragmentAdapter);
this.mViewPager.setOffscreenPageLimit(labels.size());
this.mSlidingTab.setViewPager(this.mViewPager);
if (labels != null && labels.size() <= 1) {
this.mSlidingTab.setVisibility(8);
} else if (labels != null && labels.size() > 1) {
this.mSlidingTab.setVisibility(0);
}
this.mSlidingTab.setOnPageChangeListener(new SimpleOnPageChangeListener() {
public void onPageSelected(int position) {
ShopCategoryFragment shopLabelFragment = (ShopCategoryFragment)
fragmentAdapter.getItem(position);
if (position == 0 && shopLabelFragment.isFirstLoad) {
shopLabelFragment.loadAll();
} else if (shopLabelFragment.isFirstLoad) {
shopLabelFragment.loadFirst();
}
}
});
}
}
}
ShopCategoryActivity.java 文件源码
java
阅读 27
收藏 0
点赞 0
评论 0
项目:boohee_v5.6
作者:
评论列表
文章目录