我有一个包含不同问题的文件,当用户单击“下一步按钮”时,我需要一个接一个地阅读它们。但是,我只能阅读第一行和下一行,之后的布局保持不变并且不起作用。为了阅读全部问题,我将不胜感激。这是我的代码的一部分:
public class Questions {
int i = 0;
int questionCount = 0;
int category;
String question;
int questionNumber=1;
void currentQuestion(Context context, int cat) {
category = cat;
String questionFile = "";
questionFile = "VerbalSup1.txt";
questionCount = 25;
Log.i("Question", questionFile + ": " + questionCount);
try {
InputStream is = context.getAssets().open(questionFile);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
// Skips lines
for (i = 0; i< questionNumber; i++) {
reader.readLine();
}
question = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
}
void Next(){
questionNumber=questionNumber + 1;
}
这是下一个按钮:
bNext.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
questions.Next();
questions = new Questions();
questions.Next();
currentQuestion();
}
});