I need to make Toggle button programmatically On & OFF.
I need to make Toggle button programmatically On & OFF.
To change both the state and the UI of a toggle button you need to implement two functions:
toggle.setChecked(Boolean value)
toggle.setSelected(Boolean value)
setChecked() sets the intrinsic boolean associated with the view object and setSelected sets the UI.
To Toggle set and get value use the following
togg=toggleButton.getText().toString();
// Get the default value off
String off =mo.getOn();
if (off.equals("OFF")){
holder.toggleButton.setChecked(false);
}else{
holder.toggleButton.setChecked(true);
}