How do I disable sliding tabs when in contextual a

2019-06-24 05:31发布

问题:

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

When I long press an item, the contextual action bar appears and overlays the toolbar, using <item name="windowActionModeOverlay">true</item> in my styles.xml. The problem is that the Tabs are still clickable, and swipable. I have tried setClickable(false), which didn't work.

How do I make the tabs not clickable, so that I can then change the "state look" of the tabs to a disabled state, with the code in a xml file within the drawable folder, as seen 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 much appreciated thanks.

回答1:

Put a flag in your SlidingTabLayout isActionModeEnabled.

Set it every time Action mode is created and unset it on every destruction.

Based on which configure the onClick() of TabClickListener class so that if isActionModeEnabled == true then do nothing and change the background of all tabViews or whatever you want to do with it.