tablayout在点击或者滑动的时候会触发监听事件 , 当你调用这个方法的时候 会触发事件
mTablayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
Toast.makeText(mContext, "选中的"+tab.getText(), Toast.LENGTH_SHORT).show();
@Override
public void onTabUnselected(TabLayout.Tab tab) {
Toast.makeText(mContext, "未选中的"+tab.getText(), Toast.LENGTH_SHORT).show();
@Override
public void onTabReselected(TabLayout.Tab tab) {
Toast.makeText(mContext, "复选的"+tab.getText(), Toast.LENGTH_SHORT).show();