Addressing Edge Cases

If there are no more questions available, you must inform the user. This case is handled by the handleNoQuestions() method. First, you set the text and image to appropriate values, as follows:

TextSwitcher questionTextSwitcher =

(TextSwitcher) findViewById(; questionTextSwitcher.setText(getResources().getText(R.string.no_questions)); ImageSwitcher questionlmageSwitcher =

(ImageSwitcher) findViewById(; questionImageSwitcher.setImageResource(R.drawable.noquestion);

You should also take this opportunity to disable the Button controls:

Button yesButton =

(Button) findViewById(; yesButton.setEnabled(false);

Button noButton =

(Button) findViewById(; noButton.setEnabled(false);

When the application runs out of questions, the game screen looks as shown in Figure 12.5. The user is informed that there are no more questions available and is not allowed to press any of the Button controls. Instead, the user must press the Back button and return to the main menu.


The Been There, Done That! game screen when no questions are available.

Been There, Done Thatl

No more qùestiéns available. Try back' ' later. " .

Was this article helpful?

0 0

Post a comment