Search in sources :

Example 1 with CNKFixedPagerAdapter

use of com.chinaztt.fda.adapter.CNKFixedPagerAdapter in project FastDev4Android by jiangqqlmj.

the class InfoFragment method initValidata.

private void initValidata() {
    mColorSelected = FDApplication.getInstance().getResources().getColor(R.color.color_selected);
    mColorUnSelected = FDApplication.getInstance().getResources().getColor(R.color.color_unselected);
    //添加Tab标签
    addScrollView(titles);
    mScrollBar.post(new Runnable() {

        @Override
        public void run() {
            mScrollBar.scrollTo(mScrollX, 0);
        }
    });
    fragments = new ArrayList<>();
    for (int i = 0; i < 12; i++) {
        OneFragment oneFragment = new OneFragment();
        Bundle bundle = new Bundle();
        bundle.putString("extra", titles[i]);
        oneFragment.setArguments(bundle);
        fragments.add(oneFragment);
    }
    mPagerAdater = new CNKFixedPagerAdapter(getChildFragmentManager());
    mPagerAdater.setTitles(titles);
    mPagerAdater.setFragments(fragments);
    info_viewpager.setAdapter(mPagerAdater);
    info_viewpager.setOnPageChangeListener(this);
}
Also used : CNKFixedPagerAdapter(com.chinaztt.fda.adapter.CNKFixedPagerAdapter) Bundle(android.os.Bundle)

Example 2 with CNKFixedPagerAdapter

use of com.chinaztt.fda.adapter.CNKFixedPagerAdapter in project FastDev4Android by jiangqqlmj.

the class TabInfoFragment method initValidata.

private void initValidata() {
    fragments = new ArrayList<>();
    for (int i = 0; i < 12; i++) {
        OneFragment oneFragment = new OneFragment();
        Bundle bundle = new Bundle();
        bundle.putString("extra", titles[i]);
        oneFragment.setArguments(bundle);
        fragments.add(oneFragment);
    }
    //创建Fragment的 ViewPager 自定义适配器
    mPagerAdater = new CNKFixedPagerAdapter(getChildFragmentManager());
    //设置显示的标题
    mPagerAdater.setTitles(titles);
    //设置需要进行滑动的页面Fragment
    mPagerAdater.setFragments(fragments);
    info_viewpager.setAdapter(mPagerAdater);
    tab_layout.setupWithViewPager(info_viewpager);
    //设置Tablayout
    //设置TabLayout模式 -该使用Tab数量比较多的情况
    tab_layout.setTabMode(TabLayout.MODE_SCROLLABLE);
    //设置自定义Tab--加入图标的demo
    for (int i = 0; i < 12; i++) {
        TabLayout.Tab tab = tab_layout.getTabAt(i);
        tab.setCustomView(mPagerAdater.getTabView(i));
    }
}
Also used : CNKFixedPagerAdapter(com.chinaztt.fda.adapter.CNKFixedPagerAdapter) Bundle(android.os.Bundle) TabLayout(android.support.design.widget.TabLayout)

Aggregations

Bundle (android.os.Bundle)2 CNKFixedPagerAdapter (com.chinaztt.fda.adapter.CNKFixedPagerAdapter)2 TabLayout (android.support.design.widget.TabLayout)1