-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainActivity.java
More file actions
62 lines (52 loc) · 1.94 KB
/
Copy pathMainActivity.java
File metadata and controls
62 lines (52 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
Author: Gautham Radheepan
This is the main class where you initially get to choose which category of quizzes you would like to do
*/
package com.example.simple_quiz;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
Button sportsbtn,compscibtn,genknowbtn;
TextView edttext;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
sportsbtn = findViewById(R.id.sportsbtn);
compscibtn = findViewById(R.id.compscibtn);
genknowbtn = findViewById(R.id.genknowbtn);
edttext = findViewById(R.id.screen);
//checks to see which quiz to go to once you click on a button
sportsbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
openSportsQuiz();
}
});
compscibtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
openComputerScienceQuiz();
}
});
genknowbtn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v){
openGeneralKnowledgeQuiz();
}
});
}
private void openSportsQuiz() {
Intent intent = new Intent(MainActivity.this,SportsQuiz.class);
startActivity(intent);
}
private void openComputerScienceQuiz() {
Intent intent = new Intent(MainActivity.this,ComputerScienceQuiz.class);
startActivity(intent);
}
private void openGeneralKnowledgeQuiz(){
Intent intent = new Intent(MainActivity.this,GeneralKnowledgeQuiz.class);
startActivity(intent);
}
}