Skip to content

Instantly share code, notes, and snippets.

@gmsetiawan
Created July 6, 2014 10:17
Show Gist options
  • Select an option

  • Save gmsetiawan/da535d79acc4ef13a255 to your computer and use it in GitHub Desktop.

Select an option

Save gmsetiawan/da535d79acc4ef13a255 to your computer and use it in GitHub Desktop.
final ToggleButton tB = (ToggleButton) findViewById(R.id.toggleButton1);
final TextView tBStatus = (TextView) findViewById(R.id.textView2);
tB.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
// TODO Auto-generated method stub
boolean on = tB.isChecked();
if (on) {
tBStatus.setText("On");
} else {
tBStatus.setText("Off");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment