You can do this by 2 options:
Option 1: By setting its xml attributes
`android:textOff="TEXT OFF"
android:textOn="TEXT ON"`
Option 2: Programmatically
Set the attribute onClick: methodNameHere (mine is toggleState) Then write this code:
public void toggleState(View view) {
boolean toggle = ((ToogleButton)view).isChecked();
if (toggle){
((ToogleButton)view).setTextOn("TEXT ON");
} else {
((ToogleButton)view).setTextOff("TEXT OFF");
}
}
PS: it works for me, hope it works for you too