你能幫我嗎?爲什麼這不起作用?我怎樣才能使它工作!謝謝:) 該應用程序只是總是顯示「我關掉了!」。ToggleButton - >更改TextView
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ToggleButton b = (ToggleButton)findViewById(R.id.Button);
TextView t = (TextView)findViewById(R.id.Field);
if (b.isChecked() == false){
t.setText("I'm turned off!");
}
if (b.isChecked()==true)
t.setText("I'm turned on!");
}
謝謝!這對我有效:)雖然我不得不讓B和T最終! – NiDev