ラジオボタンをラジオグループに動的に追加しようとしていますが、ボタンが表示されません。ただし、テキストはそうです。私は初心者なので、間違ったことをすべて指摘してください。
APKv7(2.1だと思います)を使用しています。
package test.test2;
import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
public class TipsActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
//create objects
ScrollView scrollv = new ScrollView(this);
LinearLayout linlay = new LinearLayout(this);
linlay.setOrientation(LinearLayout.VERTICAL);
scrollv.addView(linlay);
int currentQuestion = 0, questions = 3;
int [] answers = new int[4];
answers[0] = 3;
answers[1] = 3;
answers[2] = 4;
answers[3] = 6;
while (questions > currentQuestion) {
RadioGroup rg = new RadioGroup(this);
TextView tv = new TextView(this);
tv.setText("Question no. " + currentQuestion);
int currentAnswer = 0;
while (currentAnswer > answers[currentQuestion]) {
RadioButton rb = new RadioButton(this);
//rb.setText("Answer no. " + currentAnswer);
rg.addView(rb);
currentAnswer++;
}
linlay.addView(rg);
linlay.addView(tv);
currentQuestion++;
}
setContentView(scrollv);
}
}
(notEnoughContext notEnoughContext)