Android Radio Button inside Submit Button?
code...
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
rg.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
String id = Integer.toString(checkedId);
DisplayToast(Integer.toString(checkedId));
}
开发者_StackOverflow中文版 });
}
});
What i am trying to do is have a user select one of the radio buttons (in rg) and then when they click on submit then the toast is displayed. I think the issue is that the onchecklistener can not be inside another listener...is this possible to do?
The radio buttons are created dynamically and added to rg(radio Group)...
while (cursor.moveToNext()) {
rb[i] = new RadioButton(this);
rg.addView(rb[i]);
rb[i].setText(cursor.getString(1));
i ++;
}
I hope I understand correctly what you want to do. Just set up a listener for the submit button and inside the method, read the selected checkbox.
精彩评论