0

各linearlayoutにLinearLayoutとradiobuttonを動的に作成しました...しかし、それらのradioButtonをグループ化したいのですが、それを行うことができません...

LinearLayout linearlayout = (LinearLayout) findViewById(R.id.player_point_entry);

    TextView[] TVplayer = new TextView[number_of_player];
    EditText[] ETpoint = new EditText[number_of_player];
    EditText[] ETmaal = new EditText[number_of_player];
    RadioButton[] won = new RadioButton[number_of_player];
    RadioGroup RG_won = new RadioGroup(this);

    LinearLayout[] dyn_linearLayout = new LinearLayout[number_of_player];

    for(int i =0; i<number_of_player; i++)
    {
        dyn_linearLayout[i] = new LinearLayout(this);
        dyn_linearLayout[i].setPadding(5, 5, 5, 5);
        dyn_linearLayout[i].setOrientation(LinearLayout.HORIZONTAL);
        dyn_linearLayout[i].setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

            TVplayer[i] = new TextView(this);
                TVplayer[i].setText(player_name[i]);
                TVplayer[i].setTypeface(face);
                TVplayer[i].setTextSize(15);
                TVplayer[i].setTextColor(Color.BLACK);
                TVplayer[i].setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, 1f));

            ETpoint[i] = new EditText(this);
                ETpoint[i].setHint("Point");
                ETpoint[i].setLayoutParams(new LinearLayout.LayoutParams(70, LayoutParams.WRAP_CONTENT, 1f));

            ETmaal[i] = new EditText(this);
                ETmaal[i].setHint("Maal");
                ETmaal[i].setLayoutParams(new LinearLayout.LayoutParams(70, LayoutParams.WRAP_CONTENT, 1f));

            won[i] = new RadioButton(this);
                won[i].setChecked(true);
                won[i].setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
                won[i].setChecked(false);

            dyn_linearLayout[i].addView(TVplayer[i]);
            dyn_linearLayout[i].addView(ETpoint[i]);
            dyn_linearLayout[i].addView(ETmaal[i]);
            dyn_linearLayout[i].addView(won[i]);

            linearlayout.addView(dyn_linearLayout[i]);

    }

助けてください...上記のコードでは、RadioButtonを別のLinearLayoutに追加できますが、それらをグループ化できます...

前もって感謝します

4

1 に答える 1

0

プログラムでRadioGroupを設定できます。この質問を確認してください:プログラムでRadioGroupを設定する

于 2012-10-09T15:47:26.103 に答える