CommonTab实现类似qq消息数

2019/7/22 15:11:03 人评论 次浏览 分类:学习教程

//注意要写ArrayList 而不是list
private ArrayList<CustomTabEntity> list = new ArrayList<>();
list.add(new MyTab("消息",R.drawable.frown,R.drawable.frown2));
list.add(new MyTab("好友",R.drawable.frown,R.drawable.frown2));
list.add(new MyTab("我的",R.drawable.frown,R.drawable.frown2));
list.add(new MyTab("首页",R.drawable.frown,R.drawable.frown2));
list.add(new MyTab("内容",R.drawable.frown,R.drawable.frown2));
commonTabLayout.setTabData(list);
commonTabLayout.setOnTabSelectListener(new OnTabSelectListener() {
    @Override
    public void onTabSelect(int position) {
        
        commonTabLayout.hideMsg(position);
        if(position == 0){
            getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,fragment1).commit();
        }else if(position == 1){
            getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,fragment2).commit();
        }else if(position == 2){
            getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,fragment3).commit();
        }else if(position == 3){
            getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,fragment4).commit();
        }else if(position == 4){
            getSupportFragmentManager().beginTransaction().replace(R.id.frameLayout,fragment5).commit();
        }
    }

    @Override
    public void onTabReselect(int position) {

    }
});
//显示小红点
commonTabLayout.showDot(1);
//显示消息数 
commonTabLayout.showMsg(2,99);

相关资讯

    暂无相关的资讯...

共有访客发表了评论 网友评论

验证码: 看不清楚?
    -->