1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
class ShowQuestion extends Activity
{
public static final String EXTRA_QUESTION_NUMBER = "qnum";
private int questionNumber;
public void onCreate(Bundle extras)
{
super.onCreate(extras);
setContentView(...);
this.questionNumber = 1;
if (extras != null) {
this.questionNumber = extras.getInt(EXTRA_QUESTION_NUMBER);
String questionText = getQuestionText(this.questionNumber);
((TextView)findViewById(R.id.questiontext)).setText(questionText);
}
public void onNext()
{
Intent nextIntent = new Intent(this,ShowQuestion.class);
nextIntent.putExtra(EXTRA_QUESTION_NUMBER,this.questionNumber + 1);
startActivity(nextIntent);
}
} |
Partager