public class

SlidingTab

extends ViewGroup
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ com.droidux.pack.commons.widget.SlidingTab

Class Overview

A special widget containing two Sliders and a threshold for each. Moving either slider beyond the threshold will cause the registered OnTriggerListener.onTrigger() to be called with whichHandle being LEFT_HANDLE or RIGHT_HANDLE Equivalently, selecting a tab will result in a call to onGrabbedStateChange(View, int) with one of these two states. Releasing the tab will result in whichHandle being NO_HANDLE.

Summary

Nested Classes
interface SlidingTab.OnTriggerListener Interface definition for a callback to be invoked when a tab is triggered by moving it beyond a threshold. 
XML Attributes
Attribute Name Related Method Description
android:orientation  
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
Fields
public static final int HORIZONTAL If the android:orientation attribute is set to this value, the view will have horizontal orientation.
public static final int VERTICAL If the android:orientation attribute is set to this value, the view will have vertical orientation.
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
SlidingTab(Context context)
SlidingTab(Context context, AttributeSet attrs)
Constructor used when this widget is created from a layout file.
Public Methods
boolean onInterceptTouchEvent(MotionEvent event)
Implement this method to intercept all touch screen motion events.
boolean onTouchEvent(MotionEvent event)
Implement this method to handle touch screen motion events.
void reset(boolean animate)
Reset the tabs to their original state and stop any existing animation.
void setHoldAfterTrigger(boolean holdLeft, boolean holdRight)
void setLeftHintText(int resId)
Sets the left handle hint text to a given resource string.
void setLeftTabResources(int iconId, int targetId, int barId, int tabId)
Sets the left handle icon to a given resource.
void setOnTriggerListener(SlidingTab.OnTriggerListener listener)
Registers a callback to be invoked when the user triggers an event.
void setRightHintText(int resId)
Sets the left handle hint text to a given resource string.
void setRightTabResources(int iconId, int targetId, int barId, int tabId)
Sets the right handle icon to a given resource.
void setVisibility(int visibility)
Set the enabled state of this view.
Protected Methods
void onLayout(boolean changed, int l, int t, int r, int b)
Called from layout when this view should assign a size and position to each of its children.
void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

[Expand]
Inherited Methods
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

XML Attributes

android:orientation

Since: API Level

Related Methods

Fields

public static final int HORIZONTAL

Since: API Level 2.5

If the android:orientation attribute is set to this value, the view will have horizontal orientation.

public static final int VERTICAL

Since: API Level 2.5

If the android:orientation attribute is set to this value, the view will have vertical orientation.

Public Constructors

public SlidingTab (Context context)

Since: API Level 2.5

public SlidingTab (Context context, AttributeSet attrs)

Since: API Level 2.5

Constructor used when this widget is created from a layout file.

Public Methods

public boolean onInterceptTouchEvent (MotionEvent event)

Since: API Level

Implement this method to intercept all touch screen motion events. This allows you to watch events as they are dispatched to your children, and take ownership of the current gesture at any point.

Using this function takes some care, as it has a fairly complicated interaction with View.onTouchEvent(MotionEvent), and using it requires implementing that method as well as this one in the correct way. Events will be received in the following order:

  1. You will receive the down event here.
  2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
  3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
  4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.

Parameters
event The motion event being dispatched down the hierarchy.
Returns
  • Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.

public boolean onTouchEvent (MotionEvent event)

Since: API Level

Implement this method to handle touch screen motion events.

If this method is used to detect click actions, it is recommended that the actions be performed by implementing and calling performClick(). This will ensure consistent system behavior, including:

  • obeying click sound preferences
  • dispatching OnClickListener calls
  • handling ACTION_CLICK when accessibility features are enabled

Parameters
event The motion event.
Returns
  • True if the event was handled, false otherwise.

public void reset (boolean animate)

Since: API Level 2.5

Reset the tabs to their original state and stop any existing animation. Animate them back into place if animate is true.

public void setHoldAfterTrigger (boolean holdLeft, boolean holdRight)

Since: API Level 2.5

public void setLeftHintText (int resId)

Since: API Level 2.5

Sets the left handle hint text to a given resource string.

public void setLeftTabResources (int iconId, int targetId, int barId, int tabId)

Since: API Level 2.5

Sets the left handle icon to a given resource. The resource should refer to a Drawable object, or use 0 to remove the icon.

Parameters
iconId the resource ID of the icon drawable
targetId the resource of the target drawable
barId the resource of the bar drawable (stateful)
tabId the resource of the

public void setOnTriggerListener (SlidingTab.OnTriggerListener listener)

Since: API Level 2.5

Registers a callback to be invoked when the user triggers an event.

Parameters
listener the OnDialTriggerListener to attach to this view

public void setRightHintText (int resId)

Since: API Level 2.5

Sets the left handle hint text to a given resource string.

public void setRightTabResources (int iconId, int targetId, int barId, int tabId)

Since: API Level 2.5

Sets the right handle icon to a given resource. The resource should refer to a Drawable object, or use 0 to remove the icon.

Parameters
iconId the resource ID of the icon drawable
targetId the resource of the target drawable
barId the resource of the bar drawable (stateful)
tabId the resource of the

public void setVisibility (int visibility)

Since: API Level

Set the enabled state of this view.

Parameters
visibility One of VISIBLE, INVISIBLE, or GONE.

Protected Methods

protected void onLayout (boolean changed, int l, int t, int r, int b)

Since: API Level 2.5

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed This is a new size or position for this view
l Left position, relative to parent
t Top position, relative to parent
r Right position, relative to parent
b Bottom position, relative to parent

protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)

Since: API Level

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.