Hi,
My project is a quiz type app which downloads data from a MySQL database and displays it in a custom dialog box. I've made 2 custom dialog boxes; one for the question and one for the answer/explanation. I've got it working so once a button on main view is clicked it displays the question dialog box but I want to make it so when clicking the 'continue' button on that dialog box, the custom answer dialog box will show. Despite my code making logical sense to me, it does not seems to work and perhaps a fresh pair of eyes could bring light to this dilemma.
Any help would be much appreciated.
/** Question Custom Dialog */
if (view == findViewById(R.id.DialogBox)) {
//List items
final CharSequence[] items = {rs_wronganswer1, rs_wronganswer2, rs_correctanswer};
Collections.shuffle(Arrays.asList(items));
//Prepare the list dialog box
final Dialog dialog = new Dialog(context);
//Set its title
dialog.setTitle("Question 1");
dialog.setContentView(R.layout.alertdialogmain);
dialog.setCancelable(true);
TextView text = (TextView)dialog.findViewById(R.id.textView1);
text.setText(rs_question);
final android.widget.RadioButton rbutton1 = (android.widget.RadioButton)dialog.findViewById(R.id.radioButton1);
final android.widget.RadioButton rbutton2 = (android.widget.RadioButton)dialog.findViewById(R.id.radioButton2);
final android.widget.RadioButton rbutton3 = (android.widget.RadioButton)dialog.findViewById(R.id.radioButton3);
rbutton1.setText(items[0]);
rbutton2.setText(items[1]);
rbutton3.setText(items[2]);
final Button ContinueButton = (Button) dialog.findViewById(R.id.ContinueQ);
dialog.show();
ContinueButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
//need to check if they've got the right answer
if (rbutton1.isChecked()) {
CharSequence Rbutton1Text = rbutton1.getText();
if (Rbutton1Text.equals(rs_correctanswer)) {
UserRorW = "Correct";
} else UserRorW = "Incorrect";
}
if (rbutton2.isChecked()) {
CharSequence Rbutton2Text = rbutton2.getText();
if (Rbutton2Text.equals(rs_correctanswer)) {
UserRorW = "Correct";
} else UserRorW = "Incorrect";
}
if (rbutton3.isChecked()) {
CharSequence Rbutton3Text = rbutton3.getText();
if (Rbutton3Text.equals(rs_correctanswer)) {
UserRorW = "Correct";
} else UserRorW = "Incorrect";
}
dialog.dismiss();
/**Answer page custom dialog */
//Eclipse doesn't seem to like the code in the line below
final Dialog AnswerDialog = new Dialog(context);
//Set its title
AnswerDialog.setTitle("You were...");
AnswerDialog.setContentView(R.layout.answerpage);
AnswerDialog.setCancelable(true);
TextView VerdictText = (TextView)AnswerDialog.findViewById(R.id.VerdictA);
VerdictText.setText(UserRorW);
TextView ExplanationText = (TextView)AnswerDialog.findViewById(R.id.ExplanationA);
ExplanationText.setText(/*need to add explanation json data in here */ "");
final android.widget.Button NextQButtonA = (android.widget.Button)AnswerDialog.findViewById(R.id.ExplanationA);
final android.widget.Button CancelButtonA = (android.widget.Button)AnswerDialog.findViewById(R.id.CancelA);
AnswerDialog.show();