Created
December 2, 2021 11:48
-
-
Save codinginflow/a1c6a4d5f26d7e681abee3533894628d to your computer and use it in GitHub Desktop.
Quiz App with SQLite Tutorial Part 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
android:background="@color/colorBackground" | |
android:padding="16dp" | |
tools:context="com.codinginflow.myawesomequiz.QuizActivity"> | |
<TextView | |
android:id="@+id/text_view_score" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Score: 0" | |
android:textColor="@android:color/black" /> | |
<TextView | |
android:id="@+id/text_view_question_count" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_below="@id/text_view_score" | |
android:text="Question: 1/x" | |
android:textColor="@android:color/black" /> | |
<TextView | |
android:id="@+id/text_view_countdown" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_alignParentEnd="true" | |
android:text="00:30" | |
android:textColor="@android:color/black" | |
android:textSize="40sp" /> | |
<TextView | |
android:id="@+id/text_view_question" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_above="@id/radio_group" | |
android:layout_marginBottom="16dp" | |
android:text="Here will be the question text\nHere will be the question text\nHere will be the question text" | |
android:textAlignment="center" | |
android:textColor="@android:color/black" | |
android:textSize="20sp" /> | |
<RadioGroup | |
android:id="@+id/radio_group" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerVertical="true"> | |
<RadioButton | |
android:id="@+id/radio_button1" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Option 1" /> | |
<RadioButton | |
android:id="@+id/radio_button2" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Option 2" /> | |
<RadioButton | |
android:id="@+id/radio_button3" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:text="Option 3" /> | |
</RadioGroup> | |
<Button | |
android:id="@+id/button_confirm_next" | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" | |
android:layout_below="@id/radio_group" | |
android:layout_marginTop="16dp" | |
android:text="Confirm" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
android:background="@color/colorBackground" | |
android:padding="16dp" | |
tools:context="com.codinginflow.myawesomequiz.StartingScreenActivity"> | |
<TextView | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true" | |
android:layout_marginTop="30dp" | |
android:text="My Awesome Quiz" | |
android:textColor="@android:color/black" | |
android:textSize="35sp" /> | |
<TextView | |
android:id="@+id/text_view_highscore" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_above="@id/button_start_quiz" | |
android:layout_centerHorizontal="true" | |
android:layout_marginBottom="32dp" | |
android:text="Highscore: 0" | |
android:textSize="20sp" /> | |
<Button | |
android:id="@+id/button_start_quiz" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerInParent="true" | |
android:text="Start Quiz" /> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<resources> | |
<color name="colorPrimary">#795548</color> | |
<color name="colorPrimaryDark">#5D4037</color> | |
<color name="colorAccent">#FFEB3B</color> | |
<color name="colorBackground">#BCAAA4</color> | |
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codinginflow.myawesomequiz; | |
public class Question { | |
private String question; | |
private String option1; | |
private String option2; | |
private String option3; | |
private int answerNr; | |
public Question() { | |
} | |
public Question(String question, String option1, String option2, String option3, int answerNr) { | |
this.question = question; | |
this.option1 = option1; | |
this.option2 = option2; | |
this.option3 = option3; | |
this.answerNr = answerNr; | |
} | |
public String getQuestion() { | |
return question; | |
} | |
public void setQuestion(String question) { | |
this.question = question; | |
} | |
public String getOption1() { | |
return option1; | |
} | |
public void setOption1(String option1) { | |
this.option1 = option1; | |
} | |
public String getOption2() { | |
return option2; | |
} | |
public void setOption2(String option2) { | |
this.option2 = option2; | |
} | |
public String getOption3() { | |
return option3; | |
} | |
public void setOption3(String option3) { | |
this.option3 = option3; | |
} | |
public int getAnswerNr() { | |
return answerNr; | |
} | |
public void setAnswerNr(int answerNr) { | |
this.answerNr = answerNr; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codinginflow.myawesomequiz; | |
import android.provider.BaseColumns; | |
public final class QuizContract { | |
private QuizContract() { | |
} | |
public static class QuestionsTable implements BaseColumns { | |
public static final String TABLE_NAME = "quiz_questions"; | |
public static final String COLUMN_QUESTION = "question"; | |
public static final String COLUMN_OPTION1 = "option1"; | |
public static final String COLUMN_OPTION2 = "option2"; | |
public static final String COLUMN_OPTION3 = "option3"; | |
public static final String COLUMN_ANSWER_NR = "answer_nr"; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.codinginflow.myawesomequiz; | |
import android.content.Intent; | |
import android.support.v7.app.AppCompatActivity; | |
import android.os.Bundle; | |
import android.view.View; | |
import android.widget.Button; | |
public class StartingScreenActivity extends AppCompatActivity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_starting_screen); | |
Button buttonStartQuiz = findViewById(R.id.button_start_quiz); | |
buttonStartQuiz.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
startQuiz(); | |
} | |
}); | |
} | |
private void startQuiz() { | |
Intent intent = new Intent(StartingScreenActivity.this, QuizActivity.class); | |
startActivity(intent); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment