SmartTabLayout顶部切换

移动开发 waitig 553℃ 百度已收录 0评论

public abstract class BaseSmartTabFragment extends BseFragment {
@BindView(R.id.viewpagertab)
protected SmartTabLayout mViewpagertab;
@BindView(R.id.viewpager)
protected ViewPager mViewpager;
protected List mSmartTabInfos;

@Override
protected View initView() {
    View view = LayoutInflater.from(mContext).inflate(R.layout.fragment_base_smarttab, null);
    return view;
}

@Override
protected void initData() {
    super.initData();
    mSmartTabInfos = new ArrayList<>();
    initSmartTabinfo();
    MyNewsTabPagerAdapter myNewsTabPagerAdapter = new
            MyNewsTabPagerAdapter(getChildFragmentManager(), mSmartTabInfos, mContext);
    mViewpager.setAdapter(myNewsTabPagerAdapter);
    mViewpagertab.setViewPager(mViewpager);
}

protected abstract void initSmartTabinfo();

}

public class NewsTabFragment extends BaseSmartTabFragment{
@Override
protected void initSmartTabinfo() {
mSmartTabInfos.add(new SmartTabInfo(NewsPagerFragment.class, “资讯”, null));
mSmartTabInfos.add(new SmartTabInfo(NewsPagerFragment.class, “热点”, null));
mSmartTabInfos.add(new SmartTabInfo(NewsPagerFragment.class, “博客”, null));
mSmartTabInfos.add(new SmartTabInfo(NewsPagerFragment.class, “推荐”, null));
}
}

public class SmartTabInfo {
public Class clz;
public String title;
public Bundle args;

public SmartTabInfo( Class clz,String title, Bundle args) {
    this.title = title;
    this.args = args;
    this.clz = clz;
}

}
//fragment_base_smarttab.xml


本文由【waitig】发表在等英博客
本文固定链接:SmartTabLayout顶部切换
欢迎关注本站官方公众号,每日都有干货分享!
等英博客官方公众号
点赞 (0)分享 (0)