int count = topics.size();
Random r = new Random();
int index = r.nextInt(count);
while (al.indexOf(index) != -1) {
index = r.nextInt(count);
}
al.add(index);// 已选择的题目
// scroll view
ScrollView sv = new ScrollView(this);
RelativeLayout.LayoutParams svp = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.FILL_PARENT,
RelativeLayout.LayoutParams.FILL_PARENT);
sv.setLayoutParams(svp);
setContentView(sv);
Random ra = new Random();
// A选项随机抽取
int itemAIndex = ra.nextInt(4);
while (alChoseItems.indexOf(itemAIndex) != -1) {
itemAIndex = ra.nextInt(4);
}
alChoseItems.add(itemAIndex);
RadioButton rba = new RadioButton(this);
rba.setText("A." + items.get(itemAIndex));
// B选项随机抽取
int itemBIndex = ra.nextInt(4);
while (alChoseItems.indexOf(itemBIndex) != -1) {
itemBIndex = ra.nextInt(4);
}
alChoseItems.add(itemBIndex);
RadioButton rbb = new RadioButton(this);
rbb.setText("B." + items.get(itemBIndex));
// C选项随机抽取
int itemCIndex = ra.nextInt(4);
while (alChoseItems.indexOf(itemCIndex) != -1) {
itemCIndex = ra.nextInt(4);
}
alChoseItems.add(itemCIndex);
RadioButton rbc = new RadioButton(this);
rbc.setText("C." + items.get(itemCIndex));
// D选项随机抽取
int itemDIndex = ra.nextInt(4);
while (alChoseItems.indexOf(itemDIndex) != -1) {
itemDIndex = ra.nextInt(4);
}
alChoseItems.add(itemDIndex);
RadioButton rbd = new RadioButton(this);
rbd.setText("D." + items.get(itemDIndex));