How to disable sliding tabs in the contextual action bar, making the tabs inaccessible for clicks?

I have a toolbar to which I linked a sliding tab using these two classes: SlidingTabLayout , SlidingTabStrip .

When I click on an element for a long time, a contextual action bar appears and the toolbar overlays using <item name="windowActionModeOverlay">true</item>.xml in my styles. The problem is that tabs are still clickable and accessible. I tried setClickable(false)that did not work.

How to make tabs inaccessible for clicks so that I can then change the “state” of the tabs to the disabled state with the code in the XML file in the drop-down folder, as shown below.

<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:state_activated="true" android:drawable="@color/primary_dark" />
<item android:drawable="@android:color/transparent" />

Any help is greatly appreciated.

+4
source share
1 answer

Put the flag in your SlidingTabLayout isActionModeEnabled.

Install it every time an Action mode is created and deletes it each time it is destroyed.

Based on which the onClick () class of the TabClickListener class is configured, so if isActionModeEnabled == true, do nothing and change the background of all tabViews or whatever you do with it.

+1
source

All Articles