Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please solve my problem #62

Open
Rmintender opened this issue Jan 31, 2021 · 2 comments
Open

Please solve my problem #62

Rmintender opened this issue Jan 31, 2021 · 2 comments

Comments

@Rmintender
Copy link

Fragments should be static

@Rmintender
Copy link
Author

image

@Rmintender
Copy link
Author

public OnClickListener guessButtonListener = new OnClickListener() {

    @Override
    public void onClick(View v) {
        Button guessButton = ((Button) v);
        String guess = guessButton.getText().toString();
        String answer = getCountryName(correctAnswer);
        ++totalGuesses; // increment number of guesses the user has made

        if (guess.equals(answer)) { // if the guess is correct
            ++correctAnswers; // increment the number of correct answers

            // display correct answer in green text
            answerTextView.setText(answer);


            disableButtons(); // disable all guess Buttons

            // if the user has correctly identified FLAGS_IN_QUIZ flags
            if (correctAnswers == FLAGS_IN_QUIZ) {
                // DialogFragment to display quiz stats and start new quiz
                DialogFragment quizResults =
                        new DialogFragment() {
                            // create an AlertDialog and return it
                            @Override
                            public Dialog onCreateDialog(Bundle bundle) {
                                AlertDialog.Builder builder =
                                        new AlertDialog.Builder(getActivity());
                                builder.setMessage(
                                        getString(R.string.results,
                                                totalGuesses,
                                                (1000 / (double) totalGuesses)));

                                // "Reset Quiz" Button
                                builder.setPositiveButton(R.string.reset_quiz,
                                        new DialogInterface.OnClickListener() {
                                            public void onClick(DialogInterface dialog,
                                                                int id) {
                                                resetQuiz();
                                            }
                                        }
                                );

                                return builder.create(); // return the AlertDialog
                            }
                        };

Repository owner deleted a comment from mrpanday93 Feb 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant