How do I disable sliding tabs when in contextual action bar, by making the tabs not clickable/swipeable?

旧城冷巷雨未停 提交于 2019-12-12 11:21:51

问题


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.



来源:https://stackoverflow.com/questions/29319986/how-do-i-disable-sliding-tabs-when-in-contextual-action-bar-by-making-the-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!