Android: How to get text of dynamically created radio button selected by the user?
Posted
by Maxood
on Stack Overflow
See other posts from Stack Overflow
or by Maxood
Published on 2010-06-18T14:19:18Z
Indexed on
2010/06/18
14:23 UTC
Read the original article
Hit count: 170
android
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
© Stack Overflow or respective owner