Android: How to get text of dynamically created radio button selected by the user?
- by Maxood
How can i retrieve the text of a dynamically created radio button
selected by the user? Here's my code:
RadioGroup radiogroup = (RadioGroup) findViewById(R.id.rdbGp1);
// layout params to use when adding each radio button
LinearLayout.LayoutParams layoutParams = new
RadioGroup.LayoutParams(
RadioGroup.LayoutParams.WRAP_CONTENT,
RadioGroup.LayoutParams.WRAP_CONTENT);
for (int i = 0; i < 4; i++){
final RadioButton newRadioButton = new RadioButton(this);
c3 = db.getAns(3);
for (int j=0;j<i;j++)
c3.moveToNext();
label = c3.getString(0);
newRadioButton.setText(label);
newRadioButton.setId(6);
radiogroup.addView(newRadioButton, layoutParams);
Waiting for the reply,
Maqsood