• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Android Quiz Game [using textview and buttons]

andronee

Lurker
Hi i am new member here, also newbie in OOP and Java/Android.. i need to finish my quiz game project. User can see 6 different questions with 4 different questions, either user get the correct of incorrect questions user will move to the next question but user will get 5 points if they answer the questions correctly. Now im a bit confused on how to display all the 6 questions on TextView plus all answers on 4 Buttons with the if of looping statements.. here is what ive done so far..






[HIGH]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity = "center"
android:orientation="vertical" >

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Score"
android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
android:id="@+id/scorenumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />

<TextView
android:id="@+id/totalquestionsanswer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:text="Number" />

<TextView
android:id="@+id/questionnumber"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />

<TextView
android:id="@+id/questionstextview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:gravity="center" >

<Button
android:id="@+id/answerbutton1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />

<Button
android:id="@+id/answerbutton2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />

<Button
android:id="@+id/answerbutton3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />

<Button
android:id="@+id/answerbutton4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >

<TextView
android:id="@+id/playerfeedback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:gravity="center"
android:text="TextView" />

</LinearLayout>[/HIGH]



[HIGH]package com.example.quizgame;


import android.os.Bundle;
import android.app.Activity;
import android.widget.TextView;
import android.view.View.OnClickListener;
import android.view.View;
import android.widget.Button;
import android.widget.ArrayAdapter;
import java.util.ArrayList;
import java.util.List;



public class play extends Activity implements OnClickListener {




private int correctanswers;
private TextView questionstextview;
private TextView questionnumber;
private TextView playerfeedback;
private int totalanswer;
private int score;
private List<Question> QuestionList;









Button answer1,answer2,answer3,answer4;
Button AnswerButtons [] = {answer1,answer2,answer3,answer4};


@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.play);

QuestionList = new ArrayList<Question>();
ArrayList <String> answer = new ArrayList<String>();

answer.add("8");
answer.add("9");
answer.add("3");
answer.add("1");
QuestionList.add(new Question("what is 4+4", answer, 0));
answer.add("17");
answer.add("20");
answer.add("15");
answer.add("14");
QuestionList.add(new Question("what is 7+8?", answer, 3));
answer.add("20");
answer.add("30");
answer.add("19");
answer.add("34");
QuestionList.add(new Question("what is 10+10?", answer, 0));
answer.add("12");
answer.add("11");
answer.add("13");
answer.add("14");
QuestionList.add(new Question("what is 6+6?", answer, 0));
answer.add("6");
answer.add("5");
answer.add("4");
answer.add("7");
QuestionList.add(new Question("what is 4+3?", answer, 3));
answer.add("7");
answer.add("9");
answer.add("10");
answer.add("11");
QuestionList.add(new Question("what is 3+7?", answer, 2));


questionstextview = (TextView) findViewById (R.id.questionstextview);

questionnumber = (TextView) findViewById (R.id.questionnumber);


















View AnswerButton1 = findViewById(R.id.answerbutton1);
AnswerButton1.setOnClickListener(this);
View AnswerButton2 = findViewById(R.id.answerbutton2);
AnswerButton2.setOnClickListener(this);
View AnswerButton3 = findViewById(R.id.answerbutton3);
AnswerButton3.setOnClickListener(this);
View AnswerButton4 = findViewById(R.id.answerbutton4);
AnswerButton4.setOnClickListener(this);





}






private void ButtonPress (Button answerButton){


if







}










public play() {




}


@Override
public void onClick(View v) {





}

}
[/HIGH]
 
Back
Top Bottom