VerticalTabLayout
VerticalTabLayout的依赖:
implementation 'q.rorbin:VerticalTabLayout:1.2.5'
VerticalTabLayout的xml:
<q.rorbin.verticaltablayout.VerticalTabLayout
android:id="@+id/class_tab"
android:layout_width="100dp"
android:layout_height="match_parent"
android:background="#EDEDED"
app:indicator_color="@color/colorPrimary"
app:indicator_width="2dp"
app:indicator_gravity="left"
app:tab_height="50dp"
android:visibility="visible"
app:tab_mode="scrollable"/>
VerticalTabLayout的适配器:
mClassTab.setTabAdapter(new TabAdapter() {
@Override
public int getCount() {//个数
return list.size();
}
@Override
public ITabView.TabBadge getBadge(int position) {
return null;
}
@Override
public ITabView.TabIcon getIcon(int position) {
return null;
}
@Override
public ITabView.TabTitle getTitle(int position) {//设置标题
ITabView.TabTitle title = new ITabView.TabTitle.Builder()
.setContent(list.get(position).getFrist_name())//从集合中获取标题
.setTextColor(Color.RED,Color.BLACK)
.build();
return title;
}
@Override//设置颜色
public int getBackground(int position) {
return 0;
}
});
VerticalTabLayout的点击事件:
mClassTab.addOnTabSelectedListener(new VerticalTabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabView tab, int position) {
List<ScoreClassBean.ClassFristShopBean.ShopListBeansBean> shopListBeans = list.get(position).getShopListBeans();//根据“position”获取新的集合数据
beans.clear();//清空集合
beans.addAll(shopListBeans);//点击后将新的数据放入集合
scoreClassAdapter = new ScoreClassAdapter(getContext(), beans);//获取RecyclerView的适配器
mClassRlv.setAdapter(scoreClassAdapter);//绑定RecyclerView的适配器
}
@Override
public void onTabReselected(TabView tab, int position) {
}
});
网友评论