Search in sources :

Example 6 with OnTabSelectListener

use of com.flyco.tablayout.listener.OnTabSelectListener in project FlycoTabLayout by H07000223.

the class CommonTabActivity method tl_2.

private void tl_2() {
    mTabLayout_2.setTabData(mTabEntities);
    mTabLayout_2.setOnTabSelectListener(new OnTabSelectListener() {

        @Override
        public void onTabSelect(int position) {
            mViewPager.setCurrentItem(position);
        }

        @Override
        public void onTabReselect(int position) {
            if (position == 0) {
                mTabLayout_2.showMsg(0, mRandom.nextInt(100) + 1);
            // UnreadMsgUtils.show(mTabLayout_2.getMsgView(0), mRandom.nextInt(100) + 1);
            }
        }
    });
    mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }

        @Override
        public void onPageSelected(int position) {
            mTabLayout_2.setCurrentTab(position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }
    });
    mViewPager.setCurrentItem(1);
}
Also used : OnTabSelectListener(com.flyco.tablayout.listener.OnTabSelectListener) ViewPager(android.support.v4.view.ViewPager)

Aggregations

OnTabSelectListener (com.flyco.tablayout.listener.OnTabSelectListener)6 ViewPager (android.support.v4.view.ViewPager)4 CustomTabEntity (com.flyco.tablayout.listener.CustomTabEntity)2 MsgView (com.flyco.tablayout.widget.MsgView)2 TabEntity (com.flyco.tablayoutsamples.entity.TabEntity)1 TabEntity (com.ximsfei.skindemo.flycotablayout.entity.TabEntity)1 SkinMsgView (skin.support.flycotablayout.widget.SkinMsgView)1