我正在尝试ToggleButton
在我的 Android 代码中使用 a ,但它似乎在其中没有任何作用,而且我不知道我做错了什么。有谁知道我做错了什么?
这是代码:
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();
} }