Android tablayout does not change the tab (clip) when clicked
•
Android
About tablayout, when I slide left or right, the next tab expands - the clip displays correctly - but when I click the tab title, it does not automatically change to the appropriate clip. Do I have to implement it manually? By default, the card swiping operation seems incredible, so you should also click
resolvent:
You can implement ontabs selectedlistener and use viewpager to change the fragment
Example:
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener()
{
@Override
public void onTabSelected(TabLayout.Tab tabSelected)
{
viewPager.setCurrentItem(tabSelected.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tabSelected){}
@Override
public void onTabReselected(TabLayout.Tab tabSelected){
}
});
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码