我想获取rabiobutton
用户选择的文本。我radiobutton
在 aradiogroup
中有 5 个,然后在 Asynctask 中使用此字段并将其插入数据库。问题是,我无法得到文本。
我所拥有的是以下
radioGroup=(RadioGroup) findViewById(R.id.radiog1);
rbmuybueno=(RadioButton) findViewById(R.id.rbmuybien);
rbbueno=(RadioButton) findViewById(R.id.rbbueno);
rbregular=(RadioButton) findViewById(R.id.rbregular);
rbmalo=(RadioButton) findViewById(R.id.rbmala);
rbmuymalo=(RadioButton)findViewById(R.id.rbmuymala);
public void validarradiobutton(){
if (rbmuybueno.isChecked() || rbbueno.isChecked() || rbmalo.isChecked() || rbregular.isChecked() || rbmuymalo.isChecked())
{
final String pregunta=preguntaa.getText().toString();
}
else
{
final AlertDialog.Builder alertaDeError2 = new AlertDialog.Builder(CalificarEvento.this);
alertaDeError2.setTitle("Advertencia");
alertaDeError2.setMessage("Selecione una alternativa para continuar.");
alertaDeError2.setPositiveButton("Entendido", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
alertaDeError2.create();
alertaDeError2.show();
}
我需要获取IF中的文本,然后将参数传递给 Asynctask
如果您有一个
RadioButton
要获取的文本,它将是:如果你有一个
RadioGroup
containsRadioButtons
,你会首先得到的 idRadioGroup
:您将通过 id 获得元素的引用:
你会得到
RadioButton
内部的索引RadioGroup
:要获取 RadioButton 的文本: