I have four tabs with ViewPager attached to the OnTabSelected.
One of the tab contains Form fields, once user make any change I shouldn't let the user move to next tab unless he saves the changes.
(In other words should throw alert on OnTabSelected instead of taking the user to next tab)
But I cannot control the TabLayout -> "addOnTabSelectedListener"
Any help would be great
binding.tabLayout.addOnTabSelectedListener(object : TabLayout.OnTabSelectedListener {
    override fun onTabSelected(tab: TabLayout.Tab) {
        if (State.isClear()) {
            showNextTab()
        } else {
            showSaveSelectionAlert()
        }
    }
    override fun onTabUnselected(tab: TabLayout.Tab) {
    }
    override fun onTabReselected(tab: TabLayout.Tab) {
    }
})
 
     
     
    