I'm trying to use a ToggleButton
inside my Android code, but it seems that it does nothing within it and I don't know what I'm doing wrong. Does anyone know what I'm doing wrong?
Here it is the code:
public class StartActivity extends ActionBarActivity { Toast t;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
} public void onToggleClicked(View view) {
boolean on = ((ToggleButton) view).isChecked();
if (true) {
t=Toast.makeText(getApplicationContext(), "Anesthesia has started",Toast.LENGTH_SHORT);
t.show();
Intent b_1=new Intent(StartActivity.this,TestService.class);
startService(b_1);
} else {
t=Toast.makeText(getApplicationContext(), "Anesthesia has ended",Toast.LENGTH_SHORT);
t.show();
} }
Why don't you call your
onToggleClicked
method?