我正在尝试创建一个测验,其中我有 10 个问题(课程)随机化,但我只想显示 5 个问题(课程),然后分数将在测验结束时显示.. 我该怎么做?请.....或者是否可以限制android中的随机化?非常感谢你的帮忙..
这是代码,如果我开始播放,则必须进行随机化:
public class Whoami extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_whoami);
Button bplay =(Button) findViewById(R.id.bplay);
bplay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Random random = new Random();
random.nextInt(10);
for (int i = 0; i < 5; i++);
{
Intent newActivity1 = new Intent(Whoami.this,Question1.class);
startActivity(newActivity1);
finish();
}
{
Intent newActivity2 = new Intent(Whoami.this,Question2.class);
startActivity(newActivity2);
finish();
}
{
Intent newActivity3 = new Intent(Whoami.this,Question3.class);
startActivity(newActivity3);
finish();
}
{
Intent newActivity4 = new Intent(Whoami.this,Question4.class);
startActivity(newActivity4);
finish();
}
{
Intent newActivity5 = new Intent(Whoami.this,Question5.class);
startActivity(newActivity5);
finish();
}
{
Intent newActivity6 = new Intent(Whoami.this,Question6.class);
startActivity(newActivity6);
finish();
}
{
Intent newActivity7 = new Intent(Whoami.this,Question7.class);
startActivity(newActivity7);
finish();
}
{
Intent newActivity8 = new Intent(Whoami.this,Question8.class);
startActivity(newActivity8);
finish();
}
{
Intent newActivity9 = new Intent(Whoami.this,Question9.class);
startActivity(newActivity9);
finish();
}
{
Intent newActivity10 = new Intent(Whoami.this,Question10.class);
startActivity(newActivity10);
finish();
}
Intent i = new Intent (Whoami.this, Score.class);
startActivity(i);
finish();
}
});
};
}