Professional Documents
Culture Documents
A REPORT
On
QUIZ APPLICATION
Submitted by
C.PRASHANTH-RA1511008010177
P.SHASHANK-RA1511008010091
In partial fulfillment
I hereby declare that the project report submitted titled “Quiz App”, is a record
of mini project which I completed in the SRM UNIVERSITY during the 5th
semester(July-December 2017)
Date :
Signature of Student
TABLE OF CONTENTS
1)ABSTRACT 3
2)CONCEPT 4
4)DESIGN 5
5)CODE 6
6)RESULT 11
ABSTRACT
1.Objectives:
2.Background
3.Targeted audiences:
SHARED PREFERENCES
Android provides many ways of storing data of an application. One of this
way is called Shared Preferences. Shared Preferences allow you to save and
retrieve data in the form of key,value pair.In order to use shared preferences,
you have to call a method getSharedPreferences() that returns a
SharedPreference instance pointing to the file that contains the values of
preferences.
List View
Android ListView is a view which groups several items and display them in
vertical scrollable list. The list items are automatically inserted to the list using
an Adapter that pulls content from a source such as an array or database. An
adapter actually bridges between UI components and the data source that fill
data into UI Component. Adapter holds the data and send the data to adapter
view, the view can take the data from adapter view and shows the data on
different views like as spinner, list view, grid view etc. The ListView and GridView
are subclasses of AdapterView and they can be populated by binding them to an
Adapter, which retrieves data from an external source and creates a View that
represents each data entry. Android provides several subclasses of Adapter that
are useful for retrieving different kinds of data and building views for an
AdapterView ( i.e. ListView or GridView). The common adapters are
ArrayAdapter,Base Adapter, CursorAdapter,
SimpleCursorAdapter,SpinnerAdapter and WrapperListAdapter
DESIGN
Block Diagram
Relative Layout
Android RelativeLayout enables you to specify how child views are positioned
relative to each other. The position of each view can be specified as relative
to sibling elements or relative to the parent.Using RelativeLayout, you can
align two elements by right border, or make one below another, centered in
the screen, centered left, and so on.
CODE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.saidu.prasproject2.MainActivity">
<Button
android:id="@+id/startu2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="21dp"
android:layout_marginStart="137dp"
android:onClick="startu"
android:text="Start" />
<TextView
android:id="@+id/ggtime"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="25dp"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true" />
<TextView
android:id="@+id/question"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/ggtime"
android:layout_marginTop="87dp" />
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="@+id/question"
android:id="@+id/radioGroup">
<RadioButton
android:id="@+id/op1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_marginTop="13dp" />
<RadioButton
android:id="@+id/op2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/op1" />
<RadioButton
android:id="@+id/op3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/op2" />
<RadioButton
android:id="@+id/op4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/op3" />
</RadioGroup>
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/ggtime"
android:layout_marginTop="41dp"
android:text="question 1"
android:onClick="q1"
/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/button2"
android:layout_toEndOf="@+id/button2"
android:text="question 2"
android:onClick="q2"/>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/button3"
android:layout_toEndOf="@+id/button3"
android:text="question 3"
android:onClick="q3"
/>
<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="next"
android:onClick="pras"
android:layout_below="@+id/radioGroup"
android:layout_toEndOf="@+id/startu2" />
<TextView
android:id="@+id/score"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_above="@+id/startu2"
android:layout_alignParentStart="true"
android:textSize="30dp" />
MAIN ACTIVITY
ackage com.example.saidu.prasproject2;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.TextView;
CountDownTimer timer;
TextView gg,question,score;
Button startu2,qq1,next,qq2,qq3;
RadioButton op1,op2,op3,op4;
SharedPreferences mPrefs;
SharedPreferences.Editor editor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gg=(TextView)findViewById(R.id.ggtime);
score=(TextView)findViewById(R.id.score);
question=(TextView)findViewById(R.id.question);
op1=(RadioButton)findViewById(R.id.op1);
op2=(RadioButton)findViewById(R.id.op2);
op3=(RadioButton)findViewById(R.id.op3);
op4=(RadioButton)findViewById(R.id.op4);
startu2=(Button)findViewById(R.id.startu2);
qq1=(Button)findViewById(R.id.button2);
qq2=(Button)findViewById(R.id.button3);
qq3=(Button)findViewById(R.id.button4);
next=(Button)findViewById(R.id.next);
next.setEnabled(false);
qq1.setEnabled(false);
qq2.setEnabled(false);
qq3.setEnabled(false);
op1.setEnabled(false);
op2.setEnabled(false);
op3.setEnabled(false);
op4.setEnabled(false);
if(op1.isChecked())
{
qq2.setBackgroundColor(Color.parseColor("#800000"));
}
if(op2.isChecked())
{
qq2.setBackgroundColor(Color.parseColor("#4d7531"));
q2o++;
}
if(op3.isChecked())
{
qq2.setBackgroundColor(Color.parseColor("#800000"));
}
if(op4.isChecked())
{
qq2.setBackgroundColor(Color.parseColor("#800000"));
}
qq3.performClick();
next.setText("Finish");
op1.setChecked(false);
op2.setChecked(false);
op3.setChecked(false);
op4.setChecked(false);
break;
case 3:
if(op1.isChecked())
{
qq3.setBackgroundColor(Color.parseColor("#4d7531"));
q2o++;
}
if(op2.isChecked())
{
qq3.setBackgroundColor(Color.parseColor("#800000"));
}
if(op3.isChecked())
{
qq3.setBackgroundColor(Color.parseColor("#800000"));
}
if(op4.isChecked())
{
qq3.setBackgroundColor(Color.parseColor("#800000"));
}
next.setEnabled(false);
op1.setChecked(false);
op2.setChecked(false);
op3.setChecked(false);
op4.setChecked(false);
op1.setEnabled(false);
op2.setEnabled(false);
op3.setEnabled(false);
op4.setEnabled(false);
score.setText("Your Score: "+q2o+"/3");
timer.cancel();
break;
default:
}
}
RESULT
The given screenshot shows the initial activity of the QUIZ app. You can see a
list view with the list of radio buttons, and upon clicking START, it will be
directed to the questions.
This image shows the first question which has 4 options amongst which one
option is right. You can see the timer running on the background. (The START
button has now been disabled)
This image shows the second question .A green light indicates that the first
question has been answered correctly by the user.
.
Image shows the third question. The first two questions have been marked
wrong which has been indicated by the two red marks.