-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTitleScreen.java
84 lines (71 loc) · 2.77 KB
/
TitleScreen.java
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package com.example.sleep_buster;
import android.content.Intent;
import android.os.CountDownTimer;
import android.support.v4.app.Fragment;
import android.support.v7.app.ActionBarActivity;
import android.view.LayoutInflater;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import java.util.Random;
public class TitleScreen extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_title_screen);
Button start1 = (Button)findViewById(R.id.start1);
Button end1 = (Button)findViewById(R.id.end1);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.title_screen, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
/*Hnin's code*/
public void Questions(View v) {
while (true){
new CountDownTimer(2000, 1000) {
String question;
int ans;
public void onTick(long millisUntilFinished) {
Random rand = new Random();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
int num1 = rand.nextInt((100) + 1);
int num2 = rand.nextInt((100) + 1);
question = String.format("What is %d plus %d", num1, num2);
ans = num1 + num2;
}
public void onFinish() {
Intent answers = new Intent(getBaseContext(), MainQuestionActivity.class); //what is getBasedContext
answers.putExtra("ans", ans);
startActivity(answers);
}
}.start();
}
}
/*Hnin's code end*/
/* public void toquestions(View view)//to next activity
{
Intent intent = new Intent(this, AskQuestionsTest.class);
EditText editText = (EditText) findViewById(R.id.edit_message);
String message = editText.getText().toString();
intent.putExtra(EXTRA_MESSAGE, message);
startActivity(intent);
}*/
}