4

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.

HaloMediaz
  • 1,251
  • 2
  • 13
  • 31

1 Answers1

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.

rahul.taicho
  • 1,339
  • 1
  • 8
  • 18
  • I've been doing some research, but cannot figure out how to set a flag. Here is what I've figured out so far. A flag is typically written like this: public static final Boolean IS_ACTION_MODE_ENABLED = false; The flag is then passed via a intent like this: Intent intent = new Intent(this, SlidingTabLayout.class); intent.putExtra(ACTION_MODE_ENABLED, true); startActivity(intent); – HaloMediaz Mar 28 '15 at 19:17
  • just add a global private boolean to your SlidingTabLayout and use public setters and getters on it that is ---> setActionModeEnabled(boolean enabled) { isActionModeEnabled = enabled; } and boolean isActionModeEnabled() { return isActionModeEnabled; ) – rahul.taicho Mar 28 '15 at 19:19
  • To use the getters and setters I'd have to create a new instance every time right? like so: SlidingTabLayout layout = new SlidingTabLayout(); layout.setActionModeEnabled(true); – HaloMediaz Mar 28 '15 at 19:47
  • You can have a global slidaingTabLayout in your activity and use the getters and setters on it without reinstantiating it – rahul.taicho Mar 29 '15 at 02:02