我正在开发一个带有两个导航按钮(背面和下一个)的测验应用程序,每个测验都有一个包含30个问题的数组。现在,当btnnext到达最后一个问题时,当你再次点击它时,它应该打开另一个活动(Review)
next = (Button)findViewById(R.id.next);
next.setVisibility(View.GONE);
next.setOnClickListener(nextListener);
private View.OnClickListener nextListener = new View.OnClickListener() {
public void onClick(View v) {
setAnswer();
quesIndex++;
if (quesIndex >= QuizFunActivity.getQuesList().length())
quesIndex = QuizFunActivity.getQuesList().length() - 1;
showQuestion(quesIndex,review);
}
};
答案 0 :(得分:0)
添加下一个活动的代码
Intent myIntent = new Intent(CurrentActivity.this, NextActivity.class);
myIntent.putExtra("key", value); //Optional parameters
CurrentActivity.this.startActivity(myIntent);
您必须检查最后一个问题并更改按钮视图文本以完成。
答案 1 :(得分:0)
next = (Button)findViewById(R.id.next);
next.setVisibility(View.GONE);
next.setOnClickListener(nextListener);
private View.OnClickListener nextListener = new View.OnClickListener() {
public void onClick(View v) {
setAnswer();
if (quesIndex != QuizFunActivity.getQuesList().length()-1) {
quesIndex++;
showQuestion(quesIndex,review);
}
else {
Intent myIntent = new Intent(CurrentActivity.this, NextActivity.class);
myIntent.putExtra("key", value); //Optional parameters
CurrentActivity.this.startActivity(myIntent);
}
if (quesIndex == QuizFunActivity.getQuesList().length()-1)
next.setText("Finish");
}
};