creating Quick rate dynamically using radio buttons
<p>I am creating an application which fetches a form for ratings, dynamically. But when I implement this code, the radio group selects 2 options (radio buttons). I want to take rating in the form of radio buttons and the user will be able to select only 1 radio button. Check my code:</p>

<pre><code>for(int i=0;i&lt;count;i++)
    {

        LinearLayout lay_hori=new LinearLayout(this);
        lay_hori.setOrientation(LinearLayout.HORIZONTAL);
        TextView optionText=new TextView(this);
        optionText.setText(current_ques.option_text[i]);
        optionText.setTextColor(Color.BLACK);
        optionText.setWidth(110);
        rg_rating[i]=new RadioGroup(this); //radio group
        rg_rating[i].setMinimumHeight(30);
        rg_rating[i].setId(i);
        rg_rating[i].setOrientation(RadioGroup.HORIZONTAL);
        for(int j=0;j&lt;4;j++)
        {
            rb_rating[j]=new RadioButton(this); //radio buttons
            rb_rating[j].setId(j);

            rg_rating[i].addView(rb_rating[j]);   
            Log.i("rg_rating[i]", ""+rg_rating[i]);
            Log.i("rb_rating[j]",""+ rb_rating[j]);

        }
        Log.i("rg_rating[i]Child", ""+rg_rating[i].getChildCount()); //it returns that each radio group has 4 child,correct

        rg_rating[i].setOnCheckedChangeListener(checkRadioGroup);

        lay_hori.addView(optionText);
        lay_hori.addView(rg_rating[i]);
        layout_main.addView(lay_hori);

    } 
</code></pre>

<p>but at run time in a radio group,radio buttons select 2 options rather than 1</p>
