I\'m using the new class provided by the design library : TabLayout. And I want in specific cases that the one I\'m using can\'t change tab anymore.
I manage to disa
In my use case, if the user is in a tab and presses one of the buttons, a calculation is launched and I don't want the user to be able to switch tabs until after the calculation is completed. So I used the answer by Vladislav Rishe but modified a little as follows...
In JAVA:
//'tabLayout' is the variable where you reference your tab layout...
//A container to save the tabs that were disabled
private ArrayList touchablesToRestore = new ArrayList();
public void enableTabs() {
for(View v: touchablesToRestore){
v.setClickable(true);
}
//After you enable them all, clear the container
touchablesToRestore.clear();
}
public void disableTabs(){
for(View v: tabLayout.getTouchables()){
//Add the tab that is being disabled to the container
touchablesToRestore.add(v);
v.setClickable(false);
}
}
So when the user taps the button to make a calculation, just before the calculation logic is called, I call disableTabs(), then once the calculation is completed and it has been displayed, I call enableTabs()...