1
我有一個收音機組,用兩個黑色和彩色按鈕定義。當我嘗試根據選擇進行計算時,什麼都不會發生。任何想法爲什麼我的單選按鈕不工作?由於Android RadioButton IsSelected無法正常工作
public void onClick(View v) {
// TODO Auto-generated method stub
EditText startingAmt = (EditText) findViewById(R.id.editText1);
RadioButton black = (RadioButton) findViewById(R.id.radio0);
RadioButton color = (RadioButton) findViewById(R.id.radio1);
if(!TextUtils.isEmpty(startingAmt.getText().toString().trim())){
TextView ***** = (TextView)findViewById(R.id.textView1);
double temp1 = 0.0,
endAmt = 0.0,
startAmt = 0.0;
String answer;
Editable editableValue1 = startingAmt.getText();
startAmt = Double.parseDouble(editableValue1.toString());
if(color.isSelected()){
temp1 = startAmt * 1.15;
endAmt = temp1 * .15;
endAmt = (double)Math.round(endAmt*10)/10;
}
if(black.isSelected()){
temp1 = startAmt * 1.10;
endAmt = temp1 * .10;
endAmt = (double)Math.round(endAmt*10)/10;
}
謝謝!我假定它被選中了,你檢查一個複選框並選擇一個單選按鈕! – Intelwalk