Question
Using Android Studio in Java: Write an application that gives the user a quiz. The main learning outcome of this phase is understanding fragments ,
Using Android Studio in Java:
Write an application that gives the user a quiz. The main learning outcome of this phase is understanding fragments, so your Second Activity must be implemented using them. You will also learn the basics of file I/O in Java and RecyclerViews. Please include comments in program explaining what everything does.
You will have three Activities, as follows:
- The initial screen requests your name and shows a list of possible quizzes. Here is how it works:
- Look for files named Quiz*.txt. The format of the data in these files is described below, but the first line is the topic. Read each file and put all of the quizzes in a list.
- Show the topics in a RecyclerView.
- The user picks a quiz and presses Next. This brings up the second activity, with the first question.
- This Activity runs the quiz and has the questions. These are multiple-choice, as shown in the screen mock-up below. Its operation is as follows:
- The question and its four answers are shown in five TextViews.
- When the user touches one of the answers, change the background color to light blue and the background of any previously-selected answer to white.
- To confirm the answer, the user must press the Answer button. This button is in a Fragment so that, when it is pressed, you can replace it with a new Fragment that either congratulates the user for a correct answer or tells them which answer is correct.
- Pressing the new fragment brings up a new question and puts back the Answer button fragment.
- Continue until all questions have been answered.
- Once all of the questions have been answered, bring up this Activity to show the persons name, the name of the quiz, and their score as, say, 9/10. That is, 9 right out of 10 questions. Return to the first Activity and show the list of quizzes.
Quiz file format:
- Line 1: the quiz topic, such as Android Sensors.
- Lines 2-6 and subsequent groups of 5 lines are the actual questions, as follows:
- The question itself, such as, Which sensor measures air pressure?
- Four answers, one per line, with the correct answer preceded by an asterisk:
- Hygrometer
- Thermometer
- *Barometer
- Parking meter
Quiz1Data.txt:
Android Sensors
Which sensor measures air pressure?
Hygrometer
Thermometer
*Barometer
Parking meter
Which class can be used to determine available sensors on a device?
*SensorManager
Sensor
SensorDevices
None of the above
Quiz2Data.txt
Android File I/O
Which object can be used to read a text file?
Reader
*Scanner
File
Keyboard
Which class has information about a file or directory?
*File
FileSystem
/dev
None of the above
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started