2

黒とカラーの2つのボタンで定義されたラジオグループがあります。選択に基づいて計算しようとしても、何も起こりません。ラジオボタンが機能しない理由はありますか?ありがとう

                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;
                }
4

2 に答える 2

9

代わりにgoforを使用isSelected()isChecked()ます。

于 2012-06-18T16:28:38.033 に答える
4

isCheckedの代わりにメソッドを使用してくださいisSelected。または、2つを含むを使用できgetCheckedRadioButtonIdます。RadioGroupRadioButtons

于 2012-06-18T16:27:50.287 に答える