Introduction

Switch control is a basic two-position UI element such as On/Off , 0/1 and odd/even.

Creation

You need to create a new com.att.widgets.lib.control.SwitchControl object and add it to your view or layout.

Full Layout code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:att="http://schemas.android.com/apk/res/com.att.control"
	android:layout_width="fill_parent" 
	android:layout_height="fill_parent"  
	android:orientation="vertical"
	android:background="@color/white" android:paddingLeft="15dp"
	android:paddingRight="15dp">

	<TextView android:id="@+id/textFieldAndroid" 
		android:layout_width="wrap_content" 
		android:layout_height="wrap_content" 
		android:text="@string/switch_control_description"  
		android:paddingTop="10dp"
		android:paddingBottom="10dp"
		/>

	<com.att.widgets.lib.control.SwitchControl
		android:layout_width="wrap_content" 
		android:layout_height="wrap_content"  
		android:id="@+id/switchCon"
	/>

	<com.att.widgets.lib.control.SwitchControl
		android:layout_width="wrap_content" 
		android:layout_height="wrap_content"  
		android:id="@+id/switchCon"
		att:switch_left_label="Off"
		att:switch_right_label="On"
	/>
	
	<com.att.widgets.lib.control.SwitchControl
		android:layout_width="wrap_content" 
		android:layout_height="wrap_content"  
		android:id="@+id/switchConDis1"
		att:switch_enabled="false" 
		att:switch_left_label="no"
		att:switch_right_label="yes"
		/>
	
	<com.att.widgets.lib.control.SwitchControl
		android:layout_width="wrap_content" 
		android:layout_height="wrap_content"  
		android:id="@+id/switchDis2"
		att:switch_enabled="false"
		att:switch_checked="true"
		att:switch_left_label="0"
		att:switch_right_label="1"
		/>
	
</LinearLayout>

Simple Switch Control
<com.att.widgets.lib.control.SwitchControl
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  
    android:id="@+id/switchCon"
/>
Left-Right labeled Switch Control
<com.att.widgets.lib.control.SwitchControl
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  
    android:id="@+id/switchCon"
    att:switch_left_label="Off"
    att:switch_right_label="On"
/>
Left-Right labeled Switch Control unchecked disabled
<com.att.widgets.lib.control.SwitchControl
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  
    android:id="@+id/switchConDis1"
    att:switch_enabled="false" 
    att:switch_left_label="no"
    att:switch_right_label="yes"
/>
	
Left-Right labeled Switch Control checked disabled
	
<com.att.widgets.lib.control.SwitchControl
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"  
    android:id="@+id/switchDis2"
    att:switch_enabled="false"
    att:switch_checked="true"
    att:switch_left_label="0"
    att:switch_right_label="1"
/>

Configuration

Attribute Type Description
att:switch_enabled boolean "false" desables control , default is true
att:switch_checked boolean "true" sets switchs into "on" (right) position, default is false
att:switch_left_label String Left label value , default ""
att:switch_right_label String Right label value , default ""

In order to be able to use custom attributes, you must declare the namespace xmlns:att

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:att="http://schemas.android.com/apk/res/com.att.control"
	android:layout_width="fill_parent" 
	android:layout_height="fill_parent"  
	android:orientation="vertical"
	android:background="@color/white">
<!-- Your code using att attributes -->
</LinearLayout