public class

SegmentedBar

extends LinearLayout
implements View.OnFocusChangeListener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.LinearLayout
         ↳ greendroid.widget.SegmentedBar

Class Overview

A SegmentedBar displays a set of Buttons. Only one segment in a SegmentedBar can be selected at a time. A SegmentedBar is very close to a TabWidget in term of functionalities.

Summary

Nested Classes
interface SegmentedBar.OnSegmentChangeListener Clients may use this listener to be notified of any changes that occurs on the SegmentBar 
[Expand]
Inherited Constants
From class android.widget.LinearLayout
From class android.view.ViewGroup
From class android.view.View
Public Constructors
SegmentedBar(Context context)
SegmentedBar(Context context, AttributeSet attrs)
SegmentedBar(Context context, AttributeSet attrs, int defStyle)
Public Methods
void addSegment(String title)
Adds a segment to the SegmentBar.
View getChildSegmentAt(int index)
Returns the view representing the segment at the index index
int getSegmentCount()
Returns the current number of segment in this SegmentBar
void onFocusChange(View v, boolean hasFocus)
void setCurrentSegment(int index)
Sets the current segment to the index index
void setDividerDrawable(Drawable dividerDrawable)
Sets the drawable that is used as divider between each segment.
void setDividerDrawable(int resId)
Sets the drawable that is used as divider between each segment.
void setDividerWidth(int width)
Sets the width of the divider that will be used as segment divider.
void setOnSegmentChangeListener(SegmentedBar.OnSegmentChangeListener listener)
Use this method to register an OnSegmentChangeListener and listen to changes that occur on this SegmentBar
[Expand]
Inherited Methods
From class android.widget.LinearLayout
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.OnFocusChangeListener
From interface android.view.ViewManager
From interface android.view.ViewParent
From interface android.view.accessibility.AccessibilityEventSource

Public Constructors

public SegmentedBar (Context context)

public SegmentedBar (Context context, AttributeSet attrs)

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

Public Methods

public void addSegment (String title)

Adds a segment to the SegmentBar. This method automatically adds a divider if needed.

Parameters
title The title of the segment to add.

public View getChildSegmentAt (int index)

Returns the view representing the segment at the index index

Parameters
index The index of the segment to retrieve
Returns
  • The view that represents the segment at index index

public int getSegmentCount ()

Returns the current number of segment in this SegmentBar

Returns
  • The number of segments in this SegmentBar

public void onFocusChange (View v, boolean hasFocus)

public void setCurrentSegment (int index)

Sets the current segment to the index index

Parameters
index The index of the segment to set. Client will be notified using this method of the segment change.

public void setDividerDrawable (Drawable dividerDrawable)

Sets the drawable that is used as divider between each segment.

Parameters
dividerDrawable The drawable to used as a divider. Note : using a ColorDrawable will not work properly as the intrinsic width of a ColorDrawable is -1.

public void setDividerDrawable (int resId)

Sets the drawable that is used as divider between each segment.

Parameters
resId The identifier of the Drawable to use.

public void setDividerWidth (int width)

Sets the width of the divider that will be used as segment divider. If the dividerWidth has not been set, the intrinsic width of the divider drawable is used.

Parameters
width Width of the divider

public void setOnSegmentChangeListener (SegmentedBar.OnSegmentChangeListener listener)

Use this method to register an OnSegmentChangeListener and listen to changes that occur on this SegmentBar

Parameters
listener The listener to use