public class

ScrollableTabHost

extends FrameLayout
implements ViewTreeObserver.OnTouchModeChangeListener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ com.droidux.pack.commons.widget.tabs.ScrollableTabHost

Class Overview

This widget enhances the TabHost widget with scroll and fling gestures. The container for the tab indicators is scrollable and the container for the tab contents is flingable. Use the setFlingable(boolean) method to turn off the fling gesture.

Summary

Nested Classes
interface ScrollableTabHost.OnTabChangeListener Interface definition for a callback to be invoked when tab changed  
interface ScrollableTabHost.TabContentFactory Makes the content of a tab when it is selected. 
class ScrollableTabHost.TabSpec A tab has a tab indicator, content, and a tag that is used to keep track of it. 
[Expand]
Inherited Constants
From class android.view.ViewGroup
From class android.view.View
Fields
protected int mCurrentTab
protected LocalActivityManager mLocalActivityManager
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ScrollableTabHost(Context context)
ScrollableTabHost(Context context, AttributeSet attrs)
Public Methods
void addTab(ScrollableTabHost.TabSpec tabSpec)
Add a tab.
void clearAllTabs()
Removes all tabs from the tab widget associated with this tab host.
boolean dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path.
boolean dispatchTouchEvent(MotionEvent ev)
Pass the touch screen motion event down to the target view, or this view if it is the target.
void dispatchWindowFocusChanged(boolean hasFocus)
Called when the window containing this view gains or loses window focus.
int getCurrentTab()
String getCurrentTabTag()
View getCurrentTabView()
View getCurrentView()
boolean getFlingable()
FrameLayout getTabContentView()
Get the FrameLayout which holds tab content
ScrollableTabWidget getTabWidget()
ScrollableTabHost.TabSpec newTabSpec(String tag)
Get a new ScrollableTabHost.TabSpec associated with this tab host.
void onTouchModeChanged(boolean isInTouchMode)
Callback method to be invoked when the touch mode changes.
void setCurrentTab(int index)
void setCurrentTabByTag(String tag)
void setFlingable(boolean fling)
void setOnTabChangedListener(ScrollableTabHost.OnTabChangeListener l)
Register a callback to be invoked when the selected state of any of the items in this list changes
void setup()

Call setup() before adding tabs if loading ScrollableTabHost using findViewById().

void setup(LocalActivityManager activityGroup)
If you are using setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity.
Protected Methods
void onAttachedToWindow()
This is called when the view is attached to a window.
void onDetachedFromWindow()
This is called when the view is detached from a window.
[Expand]
Inherited Methods
From class android.widget.FrameLayout
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.ViewTreeObserver.OnTouchModeChangeListener
From interface android.view.accessibility.AccessibilityEventSource

Fields

protected int mCurrentTab

Since: API Level 2.5

protected LocalActivityManager mLocalActivityManager

Since: API Level 2.5

Public Constructors

public ScrollableTabHost (Context context)

Since: API Level 2.5

public ScrollableTabHost (Context context, AttributeSet attrs)

Since: API Level 2.5

Public Methods

public void addTab (ScrollableTabHost.TabSpec tabSpec)

Since: API Level 2.5

Add a tab.

Parameters
tabSpec Specifies how to create the indicator and content.

public void clearAllTabs ()

Since: API Level 2.5

Removes all tabs from the tab widget associated with this tab host.

public boolean dispatchKeyEvent (KeyEvent event)

Since: API Level

Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.

Parameters
event The key event to be dispatched.
Returns
  • True if the event was handled, false otherwise.

public boolean dispatchTouchEvent (MotionEvent ev)

Since: API Level

Pass the touch screen motion event down to the target view, or this view if it is the target.

Parameters
ev The motion event to be dispatched.
Returns
  • True if the event was handled by the view, false otherwise.

public void dispatchWindowFocusChanged (boolean hasFocus)

Since: API Level

Called when the window containing this view gains or loses window focus. ViewGroups should override to route to their children.

Parameters
hasFocus True if the window containing this view now has focus, false otherwise.

public int getCurrentTab ()

Since: API Level 2.5

public String getCurrentTabTag ()

Since: API Level 2.5

public View getCurrentTabView ()

Since: API Level 2.5

public View getCurrentView ()

Since: API Level 2.5

public boolean getFlingable ()

Since: API Level 2.5

public FrameLayout getTabContentView ()

Since: API Level 2.5

Get the FrameLayout which holds tab content

public ScrollableTabWidget getTabWidget ()

Since: API Level 2.5

public ScrollableTabHost.TabSpec newTabSpec (String tag)

Since: API Level 2.5

Get a new ScrollableTabHost.TabSpec associated with this tab host.

Parameters
tag required tag of tab.

public void onTouchModeChanged (boolean isInTouchMode)

Since: API Level 2.5

Callback method to be invoked when the touch mode changes.

Parameters
isInTouchMode True if the view hierarchy is now in touch mode, false otherwise.

public void setCurrentTab (int index)

Since: API Level 2.5

public void setCurrentTabByTag (String tag)

Since: API Level 2.5

public void setFlingable (boolean fling)

Since: API Level 2.5

public void setOnTabChangedListener (ScrollableTabHost.OnTabChangeListener l)

Since: API Level 2.5

Register a callback to be invoked when the selected state of any of the items in this list changes

Parameters
l The callback that will run

public void setup ()

Since: API Level 2.5

Call setup() before adding tabs if loading ScrollableTabHost using findViewById(). However: You do not need to call setup() after getTabHost() in ScrollableTabActivity. Example:

mTabHost = (TabHost)findViewById(R.id.tabhost);
mTabHost.setup();
mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");

public void setup (LocalActivityManager activityGroup)

Since: API Level 2.5

If you are using setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity. This is done for you if you extend TabActivity.

Parameters
activityGroup Used to launch activities for tab content.

Protected Methods

protected void onAttachedToWindow ()

Since: API Level

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(android.graphics.Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

protected void onDetachedFromWindow ()

Since: API Level

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.