Comment ajouter un bouton radio dynamiquement par le nombre de chefs d'accusation?

J'ai essayé ce code..Il affiche trois boutons radio sur une seule ligne lorsque l'émulateur démarre. Mais j'ai besoin d'un bouton de l'événement pour cela. j'.e; si je clique sur le bouton, il doit demander pour le nombre de boutons radio. alors Si je donne le comte, elle doit afficher les boutons de la radio basée sur le nombre donné. Par exemple, Si je donne le compte comme 3, il doit afficher les trois boutons radio sur une seule ligne.
Votre aide est très appréciée.
Merci à l'avance.

  public class MyActivity extends Activity {
    /**
     * Called when the activity is first created.
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        for(int row=0; row < 1; row++)
        {
            LinearLayout ll = new LinearLayout(this);
            ll.setOrientation(LinearLayout.HORIZONTAL);
            for(int i = 1; i < 4; i++) {
                RadioButton rdbtn = new RadioButton(this);
                rdbtn.setId((row * 2) + i);
                rdbtn.setText("Radio " + rdbtn.getId());
                ll.addView(rdbtn);
            }
            ((ViewGroup)findViewById(R.id.radiogroup)).addView(ll);
        }
    }
    }

c'est xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                tools:context=".MainActivity" >

    <RadioGroup
            android:id="@+id/radiogroup"
            android:orientation="vertical"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"/>

    </RelativeLayout>
InformationsquelleAutor Dinesh Kumar | 2013-10-15