さまざまな質問を含むファイルがあり、ユーザーが「次へボタン」をクリックしたときにそれらを次々と読む必要があります。ただし、最初の行と次の行しか読めず、その後のレイアウトは同じままで機能しません。質問全体を読むために、いくつかの助けをいただければ幸いです。ここに私のコードの一部があります:
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();
}
});