We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,420 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Android multiple choice quiz

Hello, im trying to make a mulitple choice quiz in for android.

Im a newbie at this and i am having some difficulites with the logic.

As you can see what i have done below is create two arrays, questions and answers.
The first option within each of arrays of the answers is the correct answer.

What im after is a simple quiz really that display each of the 10 question with the corresponding answers.
if correct answer is given then the int right answers goes up.

Ant help would be great even if it sjust to get me going.

Thanks...

package ks3.mathsapp.project;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class MathsMultiplicationActivity extends Activity {


TextView quesnum;
TextView ques;
TextView ans1;
TextView ans2;
TextView ans3;
TextView ans4;

    int qno = 0;
    int right_answers = 0;
    int wrong_answers = 0;
    int rnd1;
    int rnd2;

    String Questions[]= {"How much mph does the F-Duct add to the car?",
              "What car part is considered the biggest performance variable?",
              "What car part is designed to speed up air flow at the car rear?",
              "In seconds, how long does it take for a F1 car to stop when travelling at 300km/h?",
              "How many litres of air does an F1 car consume per second?",
              "What car part can heavily influence oversteer and understeer?",
              "A third of the cars downforce can come from what?",
              "Around how much race fuel would be consumed per 100km?","The first high nose cone was introduced when?",
              "An increase in what, has led to the length of exhaust pipes being shortened drastically?"};

    String answers[] [] = {{"3","5","8","9"},
    {"Tyres","Front Wing","F-Duct","Engine"},
    {"Diffuser","Suspension","Tyres","Exhaust"},
    {"4","6","8","10"},
    {"650","10","75","450"},
    {"Suspension","Tyres","Cockpit","Chassis"},
    {"Rear Wing","Nose Cone","Chassis","Engine"},
    {"75 Litres","100 Litres","50 Litres","25 Litres"},
    {"1990","1989","1993","1992"},
    {"Engine RPM","Nose Cone Lengths","Tyre Size","Number of Races"}};

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.multiplechoice);

    // Importing all assets like buttons, text fields
    quesnum = (TextView) findViewById(R.id.questionNum);
    ques = (TextView) findViewById(R.id.question);
    ans1 = (TextView) findViewById(R.id.answer1);
    ans2 = (TextView) findViewById(R.id.answer2);
    ans3 = (TextView) findViewById(R.id.answer3);
    ans4 = (TextView) findViewById(R.id.answer4);





}

}  
2
Contributors
1
Reply
3 Hours
Discussion Span
1 Year Ago
Last Updated
2
Views
brants91
Light Poster
40 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Hi brants91, I'm currently coding a similar project to this. Your first step would be to create an Alert Dialog box or a custom dialog box (which is what I've done). The Alert Dialog box can only handle 3 answers however and if you want four choices, I suggest creating a custom dialog. Here is a helpful tutorial for creating an Alert Dialog box: List Box Tutorial

BlackStar0703
Newbie Poster
18 posts since Dec 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0780 seconds using 2.81MB