Time for action - writing more Java code

  1. Open the QuestionActivity.java file in an editor or IDE.
  2. Import the Android Resources class below the package declaration:
    import android.content.res.Resources;
    
  3. In order to start asking the questions from your strings.xml file, you'll need a method to look in the questions <string-array> and find the name of the array that contains the current question. This is not normally something you need to do with application resources their identifiers are generally known to you through the R class. In this case however, we want to work in the order defined in the questions <string-array>, making things a little bit more difficult:
    private int getQuestionID(Resources res, int index) {
    
  4. We can now look at the questions ...

Get Android User Interface Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.