app/src/main/java/edu/washington/briluu/quizdroid/AnswerFragment.java
// Also sets the text for the button telling the user
Also sets the text for the button telling the user
Also sets the text for the button telling the user
public void populateScreen(View v, Topic currentTopic, int correctAnswer) {
        TextView userAnswer = (TextView) v.findViewById(R.id.userAnswer);
        userAnswer.setText(user_option);
        TextView correctAnswerTV = (TextView) v.findViewById(R.id.correctAnswer);
        correctAnswerTV.setText(currentTopic.getQuestions().get(total - 1).getAnswers()[correctAnswer - 1]);
        final int numQuestions = currentTopic.getQuestions().size();
        nextBtn = (Button) v.findViewById(R.id.next);
        if (total >= numQuestions) {
            String answersCorrectText = "You have " + correct + " out of " + total + " correct." +
                    "The quiz is now done! Click 'Finish' to go back to the menu.";
            TextView answersCorrect = (TextView) v.findViewById(R.id.answersCorrect);
            answersCorrect.setText(answersCorrectText);
            nextBtn.setText(R.string.finish);
        } else {
            String answersCorrectText = "You have " + correct + " out of " + total + " correct.";
            TextView answersCorrect = (TextView) v.findViewById(R.id.answersCorrect);
            answersCorrect.setText(answersCorrectText);
        }
        nextBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (total >= numQuestions) {
                    Intent intent = new Intent(getActivity(), MenuActivity.class);
                    startActivity(intent);
                } else {
                    QuestionFragment af = new QuestionFragment();
                    FragmentTransaction tx = getFragmentManager().beginTransaction();
                    tx.replace(R.id.quiz_fragment, af);
                    tx.commit();
                }
            }
        });
    }
public void populateScreen ( View v , Topic currentTopic , int correctAnswer ) { TextView userAnswer = ( TextView ) v . findViewById ( R . id . userAnswer ) ; userAnswer . setText ( user_option ) ; TextView correctAnswerTV = ( TextView ) v . findViewById ( R . id . correctAnswer ) ; correctAnswerTV . setText ( currentTopic . getQuestions ( ) . get ( total - 1 ) . getAnswers ( ) [ correctAnswer - 1 ] ) ; final int numQuestions = currentTopic . getQuestions ( ) . size ( ) ; nextBtn = ( Button ) v . findViewById ( R . id . next ) ; if ( total >= numQuestions ) { String answersCorrectText = "You have " + correct + " out of " + total + " correct." + "The quiz is now done! Click 'Finish' to go back to the menu." ; TextView answersCorrect = ( TextView ) v . findViewById ( R . id . answersCorrect ) ; answersCorrect . setText ( answersCorrectText ) ; nextBtn . setText ( R . string . finish ) ; } else { String answersCorrectText = "You have " + correct + " out of " + total + " correct." ; TextView answersCorrect = ( TextView ) v . findViewById ( R . id . answersCorrect ) ; answersCorrect . setText ( answersCorrectText ) ; } nextBtn . setOnClickListener ( new View . OnClickListener ( ) { @ Override public void onClick ( View v ) { if ( total >= numQuestions ) { Intent intent = new Intent ( getActivity ( ) , MenuActivity . class ) ; startActivity ( intent ) ; } else { QuestionFragment af = new QuestionFragment ( ) ; FragmentTransaction tx = getFragmentManager ( ) . beginTransaction ( ) ; tx . replace ( R . id . quiz_fragment , af ) ; tx . commit ( ) ; } } } ) ; }
Also sets the text for the button telling the user
Also sets the text for the button telling the user
// set the text from the user's previous selection // Set the text to tell the user how many questions they have answered correctly // also set the Button text to "Finish" instead of "Submit"