I need to make Toggle button programmatically On & OFF.
You can use toggleButton.setChecked(true or false)
method to make Toggle button programmatically On & OFF.
It's so simple inside your layout file
<ToggleButton android:id="@+id/ToggleButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textOff="Off Stage"
android:textOn="On Stage"/>
and in Java
ToggleButton tglbtn = (ToggleButton)findViewById(R.Id.ToggleButton01);
tglbtn.setChecked(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With