Introduction

The Image Toggle Button UI element is a simple UI item that remains active after it is pressed until it is pressed again. It has four states: enabled, pressed, active, and disabled.
An active Image Toggle Button UI element looks like this :

Creation

Activity

  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ImageToggleButton toggleButtonEnable = (ImageToggleButton)findViewById(R.id.togglebutton_enable);
	toggleButtonEnable.setFocusable(true);
  }


If you want create in disabled mode pressed

		ImageToggleButton toggleButtonDisablePressed = (ImageToggleButton)findViewById(R.id.togglebutton_disable_pressed);
		toggleButtonDisablePressed.setEnabled(false);
		toggleButtonDisablePressed.setChecked(true);

If you want create in disabled unpressed

                ImageToggleButton toggleButtonDisableUnpressed = (ImageToggleButton)findViewById(R.id.togglebutton_disable_unpressed);
		toggleButtonDisableUnpressed.setEnabled(false);
		

Layout

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

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  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 Image toggle button"/>
  	  
  <com.att.widgets.lib.button.ImageToggleButton  
  	android:id="@+id/togglebutton_enable"
  	android:layout_width="wrap_content" 
  	android:layout_height="wrap_content" 
  	android:checked="true"
  	android:layout_margin="5dip"/>
  	
  <TextView android:layout_width="fill_parent" 
  	android:layout_height="wrap_content" 
  	android:text="This is a disabled Image toggle button unpress"/>
  	
   <com.att.widgets.lib.button.ImageToggleButton  
  	android:id="@+id/togglebutton_disable_unpress"
  	android:layout_width="wrap_content" 
  	android:layout_height="wrap_content"
  	android:layout_margin="5dip"/>
  
  <TextView android:layout_width="fill_parent" 
  	android:layout_height="wrap_content" 
  	android:text="This is a disabled Image toggle button pressed"/>
  	
   <com.att.widgets.lib.button.ImageToggleButton  
  	android:id="@+id/togglebutton_disable_press"
  	android:layout_width="wrap_content" 
  	android:layout_height="wrap_content"
  	android:layout_margin="5dip"/>
  
</LinearLayout>