I have the following ToggleButton in xml:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="46dp"
android:gravity="center" >
<ToggleButton
android:id="@+id/toggleButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="ToggleButton"
android:textOff="Inactive"
android:textOn="Active" />
<TextView
android:id="@+id/label_note"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_marginRight="38dp"
android:layout_marginLeft="2dip"
android:layout_toRightOf="@+id/check_note"
android:text="@+id/label"
android:textSize="25px" />
...
</RelativeLayout>
In my class that extends a listview I would like to programatically set the togglebutton on active/inactive based on some criterias. I would like to specify that I do not what the user to be able to click on the togglebutton and set it on active or inactive. How to do that? Need some help. Appreciate!
to make the button not clickable, just disable the toggle button:
or set it not to be clickable:
and for programatically change the button state, use: