Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

I need help with this Android Studio Project I need to implement these 2 steps: Step 1 Implement Next button In the onClick method for

I need help with this Android Studio Project

I need to implement these 2 steps:

Step 1 Implement Next button

In the onClick method for the Next button, you need to do two things:

  1. Update the current index (mCurrentIndex) by increasing its value by 1. However, there are only 3 questions in the array. Therefore, you need to adjust the index accordingly.
  2. Update the text in the text view for showing the question.

Step 2. Implement True/False buttons

In the onClick method for the True and False buttons, you need to update the text in the text view showing either correct or incorrect based on which button the user clicks and the answer of the question. Remember, you need to use the string in the resources to update the text.

Below are the codes:

Java Code:

package n01059882.unf.edu; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity { private TextView mQuestionTV; private TextView mAnswerTV; private Button mTrueButton; private Button mFalseButton; private Button mNextButton; private int mCurrentIndex = 0; private int [] mQuestionBank = new int [] { R.string.question_text1, R.string.question_text2, R.string.question_text3 }; private boolean [] mAnswerBank = new boolean[] { true, false, true }; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mQuestionTV = (TextView)findViewById(R.id.question_textView); mQuestionTV.setText(R.string.question_text1); mAnswerTV = (TextView)findViewById(R.id.answer_text_view); mAnswerTV.setText(R.string.answer_text); mTrueButton = (Button)findViewById(R.id.true_button); mTrueButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); mFalseButton = (Button)findViewById(R.id.false_button); mFalseButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); mNextButton = (Button)findViewById(R.id.next_button); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mAnswerTV = +1; mAnswerTV.setText([] mAnswerBank); } }); }//end method }//end class 

The xml Code:

    

The String (Resource) Code:

 UNF Trivia True False Next Correct/Incorrect Correct Incorrect Full-stage operea productions are offered by students performers at UNF. The armadillo was never considered for mascot adoption at UNF. UNF offers Open Zip(Line) Nights for students>  

Thank you

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions