I have a problem about showing random question in my Android app. All questions are listed orderly not randomly.
Here is my code snippet shown below.
String questions[] = {
"Which method can be defined only once in a program?",
"Which of these is not a bitwise operator?",
"Which keyword is used by method to refer to the object that invoked it?",
"Which of these keywords is used to define interfaces in Java?",
"Which of these access specifiers can be used for an interface?",
"Which of the following is correct way of importing an entire package ‘pkg’?",
"What is the return type of Constructors?",
"Which of the following package stores all the standard java classes?",
"Which of these method of class String is used to compare two String objects for their equality?",
"An expression involving byte, int, & literal numbers is promoted to which of these?"
};
String answers[] = {"main method","<=","this","interface","public","import pkg.*","None of the mentioned","java","equals()","int"};
String opt[] = {
"finalize method","main method","static method","private method",
"&","&=","|=","<=",
"import","this","catch","abstract",
"Interface","interface","intf","Intf",
"public","protected","private","All of the mentioned",
"Import pkg.","import pkg.*","Import pkg.*","import pkg.",
"int","float","void","None of the mentioned",
"lang","java","util","java.packages",
"equals()","Equals()","isequal()","Isequal()",
"int","long","byte","float"
};
int flag=0;
tv=(TextView) findViewById(R.id.tvque);
rb1=(RadioButton)findViewById(R.id.radioButton);
rb2=(RadioButton)findViewById(R.id.radioButton2);
rb3=(RadioButton)findViewById(R.id.radioButton3);
rb4=(RadioButton)findViewById(R.id.radioButton4);
tv.setText(questions[flag]);
rb1.setText(opt[0]);
rb2.setText(opt[1]);
rb3.setText(opt[2]);
rb4.setText(opt[3]);
How can I define flag variable and also mix answers in Radio Buttons.