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
Based on Michele's Accepted Answer, to disable click for a single tab in Kotlin:
Inside the tabs-containing activity:
val tabs: TabLayout = findViewById(R.id.tabs)
...
(tabs.getChildAt(0) as LinearLayout).getChildAt(desiredTabPositionHere).isClickable = false
Inside the fragments (tabs):
(requireActivity().tabs.getChildAt(0) as LinearLayout).getChildAt(desiredTabPositionHere).isClickable = false
You can turn the click function on and off (by setting true
or false
). With the same method, it is also possible to modify visibility, alpha, backgroundColor etc.