public class

ScrollableTabWidget

extends RelativeLayout
implements View.OnClickListener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.RelativeLayout
         ↳ com.droidux.pack.commons.widget.tabs.ScrollableTabWidget

Class Overview

This widget is an enhancement of the TabWidget that can contain more tabs than can fit on screen at once and scroll over them. The container object for this widget is ScrollableTabHost.

Summary

Nested Classes
interface ScrollableTabWidget.OnTabSelectionChangedListener Let TabHost know that the user clicked on a tab indicator. 
[Expand]
Inherited Constants
From class android.widget.RelativeLayout
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
ScrollableTabWidget(Context context)
ScrollableTabWidget(Context context, AttributeSet attrs)
ScrollableTabWidget(Context context, AttributeSet attrs, int defStyle)
Public Methods
void addTab(View child)
Adds a tab to the list of tabs.
void addTab(int layoutResId)
Adds a tab to the list of tabs.
void dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
void focusCurrentTab(int index)
Sets the current tab and focuses the UI on it.
View getChildTabViewAt(int index)
Returns the tab indicator view at the given index.
int getCurrentTab()
Return index of the currently selected tab.
int getTabCount()
Returns the number of tab indicator views.
ViewGroup getTabParent()
Returns the ViewGroup that actually contains the tabs.
void onClick(View v)
Called when a view has been clicked.
void removeAllTabs()
void setCurrentTab(int index)
Sets the current tab.
void setTabSelectionListener(ScrollableTabWidget.OnTabSelectionChangedListener listener)
Provides a way for ViewContactActivity and EditContactActivity to be notified that the user clicked on a tab indicator.
Protected Methods
void tabScroll(boolean directionRight)
Scrolls the tabs by exactly one tab width.
void updateArrowVisibility()
void updateLeftMostVisible()
[Expand]
Inherited Methods
From class android.widget.RelativeLayout
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.View.OnClickListener
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public ScrollableTabWidget (Context context)

Since: API Level 2.5

public ScrollableTabWidget (Context context, AttributeSet attrs)

Since: API Level 2.5

public ScrollableTabWidget (Context context, AttributeSet attrs, int defStyle)

Since: API Level 2.5

Public Methods

public void addTab (View child)

Since: API Level 2.5

Adds a tab to the list of tabs. The tab's indicator view must be provided.

public void addTab (int layoutResId)

Since: API Level 2.5

Adds a tab to the list of tabs. The tab's indicator view is specified by a layout id. InflateException will be thrown if there is a problem inflating.

Parameters
layoutResId The layout id to be inflated to make the tab indicator.

public void dispatchDraw (Canvas canvas)

Since: API Level 2.5

Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).

Parameters
canvas the canvas on which to draw the view

public void focusCurrentTab (int index)

Since: API Level 2.5

Sets the current tab and focuses the UI on it. This method makes sure that the focused tab matches the selected tab, normally at setCurrentTab(int). Normally this would not be an issue if we go through the UI, since the UI is responsible for calling TabWidget.onFocusChanged(), but in the case where we are selecting the tab programmatically, we'll need to make sure focus keeps up.

Parameters
index The tab that you want focused (highlighted in orange) and selected (tab brought to the front of the widget)

public View getChildTabViewAt (int index)

Since: API Level 2.5

Returns the tab indicator view at the given index.

Parameters
index the zero-based index of the tab indicator view to return
Returns
  • the tab indicator view at the given index

public int getCurrentTab ()

Since: API Level 2.5

Return index of the currently selected tab.

public int getTabCount ()

Since: API Level 2.5

Returns the number of tab indicator views.

Returns
  • the number of tab indicator views.

public ViewGroup getTabParent ()

Since: API Level 2.5

Returns the ViewGroup that actually contains the tabs. This is where the tab views should be attached to when being inflated.

public void onClick (View v)

Since: API Level 2.5

Called when a view has been clicked.

Parameters
v The view that was clicked.

public void removeAllTabs ()

Since: API Level 2.5

public void setCurrentTab (int index)

Since: API Level 2.5

Sets the current tab. This method is used to bring a tab to the front of the Widget, and is used to post to the rest of the UI that a different tab has been brought to the foreground. Note, this is separate from the traditional "focus" that is employed from the view logic. For instance, if we have a list in a tabbed view, a user may be navigating up and down the list, moving the UI focus (orange highlighting) through the list items. The cursor movement does not effect the "selected" tab though, because what is being scrolled through is all on the same tab. The selected tab only changes when we navigate between tabs (moving from the list view to the next tabbed view, in this example). To move both the focus AND the selected tab at once, please use focusCurrentTab(int). Normally, the view logic takes care of adjusting the focus, so unless you're circumventing the UI, you'll probably just focus your interest here.

Parameters
index The tab that you want to indicate as the selected tab (tab brought to the front of the widget)

public void setTabSelectionListener (ScrollableTabWidget.OnTabSelectionChangedListener listener)

Since: API Level 2.5

Provides a way for ViewContactActivity and EditContactActivity to be notified that the user clicked on a tab indicator.

Protected Methods

protected void tabScroll (boolean directionRight)

Since: API Level 2.5

Scrolls the tabs by exactly one tab width.

Parameters
directionRight if true, scroll to the right, if false, scroll to the left.

protected void updateArrowVisibility ()

Since: API Level 2.5

protected void updateLeftMostVisible ()

Since: API Level 2.5