0
不單擊RadioButton意味着它已被選中。有代碼的例子,如這樣: -爲什麼在RadioButton的onClick中調用isChecked
public void onRadioButtonClicked(View view) {
// Is the button now checked?
boolean checked = ((RadioButton) view).isChecked();
// Check which radio button was clicked
switch(view.getId()) {
case R.id.radio_pirates:
if (checked)
// Pirates are the best
break;
case R.id.radio_ninjas:
if (checked)
// Ninjas rule
break;
}
}
一個在這裏https://developer.android.com/guide/topics/ui/controls/radiobutton.html
爲什麼我不能這樣做只是這個代替: -
public void onRadioButtonClicked(View view) {
// Check which radio button was clicked
switch(view.getId()) {
case R.id.radio_pirates:
// Pirates are the best
break;
case R.id.radio_ninjas:
// Ninjas rule
break;
}
}
感謝您的參考。這並不意味着按下或點擊它會一直檢查它嗎?那麼爲什麼isChecked()? – Himanshu