I'm implementing an Android quiz in Java where user is shown a random image and is asked to choose what he can see in it. The images are in /res/drawable
, however I'm wondering how to bind the image name and a few possible types of answers to the given image, each indicating something different about the person taking the test.
My first idea was to create a Java class serving this purpose:
public class Question {
Question(String imgSrc, String ans1, String ans2, String ans3)
{
imageSource = imgSrc;
answer1 = ans1;
answer2 = ans2;
answer3 = ans3;
}
private String imageSource;
private String answer1;
private String answer2;
private String answer3;
}
and then another class QuestionSet
where specific questions could be constructed and stored as public static objects accessible from QuestionActivity
. However, I'm reading that for some reasons static Java objects should be avoided in Android programs (as is explained here), especially when they are to last in memory for a long time as is the case with my quiz.
So my question is what the best alternative for my current approach could be.