简体   繁体   English

在上下文操作栏中,如何通过使选项卡不可单击/可滑动来禁用滑动选项卡?

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

I have a toolbar, to which I have attached a sliding tab layout, using these two classes: SlidingTabLayout , SlidingTabStrip . 我有一个工具栏,它使用以下两个类附加了滑动选项卡布局: SlidingTabLayoutSlidingTabStrip

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. 长按一个项目时,使用我的styles.xml中的<item name="windowActionModeOverlay">true</item> ,上下文操作栏就会出现并覆盖在工具栏上。 The problem is that the Tabs are still clickable, and swipable. 问题在于选项卡仍然是可单击和可滑动的。 I have tried setClickable(false) , which didn't work. 我尝试了setClickable(false) ,但是没有用。

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. 如何使选项卡不可单击,以便随后可以将选项卡的“状态外观”更改为禁用状态,并使用可绘制文件夹中xml文件中的代码,如下所示。

<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. 非常感谢任何帮助。

Put a flag in your SlidingTabLayout isActionModeEnabled. 在您的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. 基于哪个配置TabClickListener类的onClick(),以便如果isActionModeEnabled == true,则不执行任何操作,并更改所有tabViews的背景或任何您想使用的背景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM