I need to skip particular tab. When user scroll from 1st to 2nd tab control should move to 3rd tab and vice versa.
I have override the OnTabSelectedListener for Tablayout and calling below function in tabselected method, but no result.
private class TabChangeListener implements TabLayout.OnTabSelectedListener {
@Override
public void onTabSelected(TabLayout.Tab tab) {
changeTab(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
}
Method to change tab.
private void changeTab(int pos) {
if (pos == 1) {
if (previousPos == 2) {
TabLayout.Tab tab = mTabLayout.getTabAt(0);
tab.select();
} else if (previousPos == 0) {
TabLayout.Tab tab = mTabLayout.getTabAt(2);
tab.select();
}
} else
previousPos = pos;
}