public class

SegmentedView

extends View
java.lang.Object
   ↳ com.neomades.ui.View
     ↳ com.neomades.ui.SegmentedView

Class Overview

A SegmentedView object is a horizontal view with multiple segments.

Each segment is represented by a discrete button.

With ItemSelectedListener listener, the segmented may inform that the selection has been changed.

By default, the first item is selected.

Summary

[Expand]
Inherited XML Attributes
From class com.neomades.ui.View
Constants
int STYLE_BAR The iOS small toolbar style for segmented controls.
int STYLE_BEZELED The iOS large bezeled style for segmented controls.
int STYLE_BORDERED The iOS large bordered style for segmented controls.
int STYLE_PLAIN The iOS large plain style for segmented controls.
[Expand]
Inherited Constants
From interface com.neomades.ui.Alignment
From interface com.neomades.ui.StretchMode
Public Constructors
SegmentedView()
Creates a new SegmentedView.
Public Methods
void addItem(String text)
Appends a new segment with text.
int getSelectedIndex()
Returns the index number of the selected segment.
String getSelectedItem()
Returns the text of the selected segment.
void setItemSelectedListener(ItemSelectedListener listener)
Sets a listener.
void setSelectedIndex(int index)
Sets the selected segment to the given index.
void setSelectedItem(String item)
Sets the selected index to the index given in parameter.
void setStyle(int style)
Sets the style of the segmented view.
[Expand]
Inherited Methods
From class com.neomades.ui.View
From class java.lang.Object

Constants

public static final int STYLE_BAR

The iOS small toolbar style for segmented controls. Segmented controls in this style can have a tint color.

Constant Value: -3 (0xfffffffd)

public static final int STYLE_BEZELED

The iOS large bezeled style for segmented controls. Segmented controls in this style can have a tint color

Constant Value: -4 (0xfffffffc)

public static final int STYLE_BORDERED

The iOS large bordered style for segmented controls.

Constant Value: -2 (0xfffffffe)

public static final int STYLE_PLAIN

The iOS large plain style for segmented controls. This style is the default.

Constant Value: -1 (0xffffffff)

Public Constructors

public SegmentedView ()

Creates a new SegmentedView.

Public Methods

public void addItem (String text)

Appends a new segment with text.

Parameters
text the text of the new segment to add

public int getSelectedIndex ()

Returns the index number of the selected segment.

Returns
  • the selected index from this segmentedView

public String getSelectedItem ()

Returns the text of the selected segment.

Returns
  • the selected segment text from this segmentedView

public void setItemSelectedListener (ItemSelectedListener listener)

Sets a listener.

public void setSelectedIndex (int index)

Sets the selected segment to the given index.

By default, the first item is selected.

Parameters
index the index of the segment to select

public void setSelectedItem (String item)

Sets the selected index to the index given in parameter. The item selected will be the first in the segmented view that is equal to the String given in parameter.

Parameters
item the item to select
Throws
CrossThreadException if the method is called from outside the UI-Thread

public void setStyle (int style)

Sets the style of the segmented view.

Parameters
style one of STYLE_BAR, STYLE_BEZELED, STYLE_BORDERED or STYLE_PLAIN