Technical Library
Segmented Text Toggle Button for Android™
A Segmented Toggle Button UI element contains two or more toggle buttons. One button is always in the active state.
Button has three states: enabled, active, and disabled.
Download UI elements for Android.
Creation from XML
You need to create a new com.att.widgets.lib.button.SegmentedTextToggleButton object and add it to your view or layout.
<com.att.widgets.lib.button.SegmentedTextToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dip" android:layout_marginBottom="5dip"> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 1"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 2"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 3"/> </com.att.widgets.lib.button.SegmentedTextToggleButton>
Creation from Code
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); ViewGroup v = (ViewGroup)findViewById(R.id.segmented_togglebutton_main); SegmentedTextToggleButton segmentedToggle = new SegmentedTextToggleButton(this); ImageToggleButton imageToggleButton = new ImageToggleButton(this); imageToggleButton.setText("Toggle 1"); segmentedToggle.addButton(imageToggleButton); imageToggleButton = new ImageToggleButton(this); imageToggleButton.setText("Toggle 2"); segmentedToggle.addButton(imageToggleButton); segmentedToggle.init(); v.addView(segmentedToggle); }
Layout
your main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/segmented_togglebutton_main" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is a Segmented text toggle button created in the xml"/> <com.att.widgets.lib.button.SegmentedTextToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/segmented_enabled" android:layout_marginTop="5dip" android:layout_marginBottom="5dip"> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 1"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 2"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 3"/> </com.att.widgets.lib.button.SegmentedTextToggleButton> <TextView android:layout_width="wrap_content" android:id="@+id/segmented_enabled_text" android:layout_height="wrap_content" android:text="Selected toggle index= -1" android:layout_margin="10dip"/> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is a disabled Segmented text toggle button created in the xml"/> <com.att.widgets.lib.button.SegmentedTextToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/segmented_disabled" android:layout_marginTop="5dip" android:layout_marginBottom="5dip"> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 1"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 2"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 3"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 4"/> </com.att.widgets.lib.button.SegmentedTextToggleButton> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="This is a Segmented text toggle button created in code"/> </LinearLayout>
Defined in Xml and Disabled from Code
Activity
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); SegmentedTextToggleButton segmentedTextToggleButtonDisable = (SegmentedTextToggleButton)findViewById(R.id.segmented_disabled); segmentedTextToggleButtonDisable.setEnabled(false); segmentedTextToggleButtonDisable.setSelectedIndex(2); }
Layout
<com.att.widgets.lib.button.SegmentedTextToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/segmented_disabled" android:layout_marginTop="5dip" android:layout_marginBottom="5dip"> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 1"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 2"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 3"/> <com.att.widgets.lib.button.ImageToggleButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Toggle 4"/> </com.att.widgets.lib.button.SegmentedTextToggleButton>
Android is a trademark of Google Inc.
14100000
Session Expired
Sorry! Your session has expired.