テキストビューとラジオボタンを動的に含む相対レイアウトを動的に作成しました。このレイアウトをリストビュー行に拡張する必要があります。
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT );
params.addRule(RelativeLayout.ALIGN_PARENT_TOP);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
txt = new TextView(context);
txt.setId(1001);
txt.setText("Question");
txt.setTextColor(Color.BLACK);
txt.setTextSize(5);
txt.setLayoutParams(params);
RelativeLayout.LayoutParams quesParams = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT );
quesParams.addRule(RelativeLayout.BELOW,1001);
quesParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
TextView txtQues = new TextView(context);
txtQues.setId(1010);
txtQues.setText("What is the oldest civilization on earth?");
txtQues.setTextSize(10);
txtQues.setTextColor(Color.BLUE);
txtQues.setLayoutParams(quesParams);
RadioButton rdp = new RadioButton(context);
rdp.setText("Harrapa");
rdp.setTextColor(Color.BLACK);
rdp.setTextSize(10);
RadioButton rd2 = new RadioButton(context);
rd2.setText("Egypt");
rd2.setTextColor(Color.BLACK);
rd2.setTextSize(10);
RadioButton rd3 = new RadioButton(context);
rd3.setText("Egypt");
rd3.setTextColor(Color.BLACK);
rd3.setTextSize(10);
RadioButton rd4 = new RadioButton(context);
rd4.setText("kumarikandam");
rd4.setTextColor(Color.BLACK);
rd4.setTextSize(10);
RelativeLayout.LayoutParams radioGrpparms = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT );
radioGrpparms.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
radioGrpparms.addRule(RelativeLayout.BELOW, 1010);
rdgrp = new RadioGroup(context);
rdgrp.setLayoutParams(radioGrpparms);
rdgrp.addView(rdp, radioGrpparms);
rdgrp.addView(rd2, radioGrpparms);
rdgrp.addView(rd4, radioGrpparms);
RelativeLayout rel = new RelativeLayout(context);
rel.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.FILL_PARENT));
rel.addView(txt);
rel.addView(txtQues);
rel.addView(rdgrp);
rel.setId(1050);
//setContentView(rel);
rdgrp.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton view=(RadioButton)findViewById(checkedId);
Toast.makeText(context,view.getText() , Toast.LENGTH_LONG).show();
}
});
この動的に生成された相対レイアウトをリストビューの行に入力する必要があります