当前位置: 首页>>代码示例>>Java>>正文


Java SlidingTabLayout.setViewPager方法代码示例

本文整理汇总了Java中com.flyco.tablayout.SlidingTabLayout.setViewPager方法的典型用法代码示例。如果您正苦于以下问题:Java SlidingTabLayout.setViewPager方法的具体用法?Java SlidingTabLayout.setViewPager怎么用?Java SlidingTabLayout.setViewPager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.flyco.tablayout.SlidingTabLayout的用法示例。


在下文中一共展示了SlidingTabLayout.setViewPager方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import com.flyco.tablayout.SlidingTabLayout; //导入方法依赖的package包/类
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sliding_tab);

        for (String title : mTitles) {
            mFragments.add(SimpleCardFragment.getInstance(title));
        }


        View decorView = getWindow().getDecorView();
        ViewPager vp = ViewFindUtils.find(decorView, R.id.vp);
        mAdapter = new MyPagerAdapter(getSupportFragmentManager());
        vp.setAdapter(mAdapter);

        /** 默认 */
        SlidingTabLayout tabLayout_1 = ViewFindUtils.find(decorView, R.id.tl_1);
        /**自定义部分属性*/
        SlidingTabLayout tabLayout_2 = ViewFindUtils.find(decorView, R.id.tl_2);
        /** 字体加粗,大写 */
        SlidingTabLayout tabLayout_3 = ViewFindUtils.find(decorView, R.id.tl_3);
        /** tab固定宽度 */
        SlidingTabLayout tabLayout_4 = ViewFindUtils.find(decorView, R.id.tl_4);
        /** indicator固定宽度 */
        SlidingTabLayout tabLayout_5 = ViewFindUtils.find(decorView, R.id.tl_5);
        /** indicator圆 */
        SlidingTabLayout tabLayout_6 = ViewFindUtils.find(decorView, R.id.tl_6);
        /** indicator矩形圆角 */
        final SlidingTabLayout tabLayout_7 = ViewFindUtils.find(decorView, R.id.tl_7);
        /** indicator三角形 */
        SlidingTabLayout tabLayout_8 = ViewFindUtils.find(decorView, R.id.tl_8);
        /** indicator圆角色块 */
        SlidingTabLayout tabLayout_9 = ViewFindUtils.find(decorView, R.id.tl_9);
        /** indicator圆角色块 */
        SlidingTabLayout tabLayout_10 = ViewFindUtils.find(decorView, R.id.tl_10);

        tabLayout_1.setViewPager(vp);
        tabLayout_2.setViewPager(vp);
        tabLayout_2.setOnTabSelectListener(this);
        tabLayout_3.setViewPager(vp);
        tabLayout_4.setViewPager(vp);
        tabLayout_5.setViewPager(vp);
        tabLayout_6.setViewPager(vp);
        tabLayout_7.setViewPager(vp, mTitles);
        tabLayout_8.setViewPager(vp, mTitles, this, mFragments);
        tabLayout_9.setViewPager(vp);
        tabLayout_10.setViewPager(vp);

        vp.setCurrentItem(4);

        tabLayout_1.showDot(4);
        tabLayout_3.showDot(4);
        tabLayout_2.showDot(4);

        tabLayout_2.showMsg(3, 5);
        tabLayout_2.setMsgMargin(3, 0, 10);
        MsgView rtv_2_3 = tabLayout_2.getMsgView(3);
        if (rtv_2_3 != null) {
            rtv_2_3.setBackgroundColor(Color.parseColor("#6D8FB0"));
        }

        tabLayout_2.showMsg(5, 5);
        tabLayout_2.setMsgMargin(5, 0, 10);

//        tabLayout_7.setOnTabSelectListener(new OnTabSelectListener() {
//            @Override
//            public void onTabSelect(int position) {
//                Toast.makeText(mContext, "onTabSelect&position--->" + position, Toast.LENGTH_SHORT).show();
//            }
//
//            @Override
//            public void onTabReselect(int position) {
//                mFragments.add(SimpleCardFragment.getInstance("后端"));
//                mAdapter.notifyDataSetChanged();
//                tabLayout_7.addNewTab("后端");
//            }
//        });
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:79,代码来源:SlidingTabActivity.java

示例2: onCreate

import com.flyco.tablayout.SlidingTabLayout; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sliding_tab);

    for (String title : mTitles) {
        mFragments.add(SimpleCardFragment.getInstance(title));
    }

    View decorView = getWindow().getDecorView();
    ViewPager vp = ViewFindUtils.find(decorView, R.id.vp);
    vp.setAdapter(new MyPagerAdapter(getSupportFragmentManager()));

    /** 默认 */
    SlidingTabLayout tabLayout_1 = ViewFindUtils.find(decorView, R.id.tl_1);
    /**自定义部分属性*/
    SlidingTabLayout tabLayout_2 = ViewFindUtils.find(decorView, R.id.tl_2);
    /** 字体加粗,大写 */
    SlidingTabLayout tabLayout_3 = ViewFindUtils.find(decorView, R.id.tl_3);
    /** tab固定宽度 */
    SlidingTabLayout tabLayout_4 = ViewFindUtils.find(decorView, R.id.tl_4);
    /** indicator固定宽度 */
    SlidingTabLayout tabLayout_5 = ViewFindUtils.find(decorView, R.id.tl_5);
    /** indicator圆 */
    SlidingTabLayout tabLayout_6 = ViewFindUtils.find(decorView, R.id.tl_6);
    /** indicator矩形圆角 */
    SlidingTabLayout tabLayout_7 = ViewFindUtils.find(decorView, R.id.tl_7);
    /** indicator三角形 */
    SlidingTabLayout tabLayout_8 = ViewFindUtils.find(decorView, R.id.tl_8);
    /** indicator圆角色块 */
    SlidingTabLayout tabLayout_9 = ViewFindUtils.find(decorView, R.id.tl_9);
    /** indicator圆角色块 */
    SlidingTabLayout tabLayout_10 = ViewFindUtils.find(decorView, R.id.tl_10);

    tabLayout_1.setViewPager(vp);
    tabLayout_2.setViewPager(vp);
    tabLayout_2.setOnTabSelectListener(this);
    tabLayout_3.setViewPager(vp);
    tabLayout_4.setViewPager(vp);
    tabLayout_5.setViewPager(vp);
    tabLayout_6.setViewPager(vp);
    tabLayout_7.setViewPager(vp, mTitles);
    tabLayout_8.setViewPager(vp, mTitles, this, mFragments);
    tabLayout_9.setViewPager(vp);
    tabLayout_10.setViewPager(vp);

    vp.setCurrentItem(4);

    tabLayout_1.showDot(4);
    tabLayout_3.showDot(4);
    tabLayout_2.showDot(4);

    tabLayout_2.showMsg(3, 5);
    tabLayout_2.setMsgMargin(3, 0, 10);
    MsgView rtv_2_3 = tabLayout_2.getMsgView(3);
    if (rtv_2_3 != null) {
        rtv_2_3.setBackgroundColor(Color.parseColor("#6D8FB0"));
    }

    tabLayout_2.showMsg(5, 5);
    tabLayout_2.setMsgMargin(5, 0, 10);
}
 
开发者ID:wf864617223,项目名称:FlycoTabLayout-master,代码行数:63,代码来源:SlidingTabActivity.java

示例3: init

import com.flyco.tablayout.SlidingTabLayout; //导入方法依赖的package包/类
@Override
public void init(Bundle savedInstanceState) {
    setContentView(R.layout.act_device_commnunicate);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    if(getSupportActionBar() != null) {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    }


    mDevice = (BleDevice) getIntent().getSerializableExtra(AppConstants.KEY_BLE_DEVICE);
    //mDeviceName = TextUtils.isEmpty(mDevice.name) ? mDevice.address : mDevice.name;
    //mDeviceAddress = mDevice.address;

    //setTitle(mDeviceName);


    for (String title : mTitles) {
        mFragments.add(BleLogFragment.getInstance(title));
    }


    ViewPager vp = (ViewPager) findViewById(R.id.vp);
    mAdapter = new DevicePagerAdapter(getSupportFragmentManager());
    vp.setAdapter(mAdapter);

    SlidingTabLayout tabLayout_1 = (SlidingTabLayout) findViewById(R.id.tl_1);


    tabLayout_1.setViewPager(vp, mTitles, this, mFragments);

    tabLayout_1.setOnTabSelectListener(this);

    vp.setCurrentItem(0);
}
 
开发者ID:captain-miao,项目名称:bleYan,代码行数:36,代码来源:DeviceCommunicateActivity.java

示例4: setSlidingTabData

import com.flyco.tablayout.SlidingTabLayout; //导入方法依赖的package包/类
/**
 * Fragment 里SlidingTabLayout 快速设置
 *
 * @param fragment
 * @param viewPager
 * @param tittles
 * @param fragments
 * @param tabLayout
 * @param listener
 */
public void setSlidingTabData(Fragment fragment, SlidingTabLayout tabLayout, ViewPager viewPager,
                              List<String> tittles, List<Fragment> fragments, OnTabSelectListener listener) {
    setViewPager(fragment, tabLayout, viewPager, tittles, fragments, listener);
    tabLayout.setViewPager(viewPager);
}
 
开发者ID:AriesHoo,项目名称:FastLib,代码行数:16,代码来源:TabLayoutManager.java


注:本文中的com.flyco.tablayout.SlidingTabLayout.setViewPager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。