質問するログイン新規登録

質問編集履歴

1

試しに10分のボタンを押したときにカウントの時間がセットされるように書きました(実際はされません)

2020/01/23 15:01

投稿

dekinai_chan
dekinai_chan

スコア4

title CHANGED
File without changes
body CHANGED
@@ -3,7 +3,6 @@
3
3
  android studioでjavaで5分、10分、15分から時間を選べるカウントダウンタイマーのアプリを作成してるのですが、「5分」「10分」「15分」ボタンを押すとその時間がセットされるような動きをさせることができません。
4
4
  ボタンを押したときの発生するイベントに時間がセットされるように書きましたが、エラーが出てしまい動きませんでした。
5
5
  どうすればよいでしょうか?
6
- tenButton.setOnClickListener(new View.OnClickListener() (10分ボタン)の中身はなくしています。
7
6
  作りかけなので汚い文章になってるかもしれません。
8
7
  ### 発生している問題・エラーメッセージ
9
8
 
@@ -32,7 +31,7 @@
32
31
  public class MainActivity extends AppCompatActivity {
33
32
 
34
33
  private TextView timerText;
35
- long countNumber = 600000;
34
+ long countNumber = 300000;
36
35
  // インターバル msec
37
36
  long interval = 10;
38
37
  final CountDown countDown = new CountDown(countNumber, interval);
@@ -49,7 +48,7 @@
49
48
  timerText.setText(dataFormat.format(0));
50
49
  }
51
50
 
52
-
51
+ // インターバルで呼ばれる
53
52
  @Override
54
53
  public void onTick(long millisUntilFinished) {
55
54
  // 残り時間を分、秒、ミリ秒に分割
@@ -74,8 +73,6 @@
74
73
 
75
74
  Button startButton = findViewById(R.id.start_button);
76
75
  Button stopButton = findViewById(R.id.stop_button);
77
- Button shitumonButton = findViewById(R.id.shitumon_button);
78
- Button happyoButton = findViewById(R.id.happyo_button);
79
76
  Button fiveButton = findViewById(R.id.five_button);
80
77
  Button tenButton = findViewById(R.id.ten_button);
81
78
  Button fifteenButton = findViewById(R.id.fifteen_button);
@@ -90,6 +87,10 @@
90
87
  @Override
91
88
  public void onClick(View v) {
92
89
 
90
+ long countNumber = 600000;
91
+ // インターバル msec
92
+ long interval = 10;
93
+
93
94
  }
94
95
  });
95
96
 
@@ -121,29 +122,8 @@
121
122
  timerText.setText(dataFormat.format(0));
122
123
  }
123
124
  });
124
-
125
-
126
-
127
- shitumonButton.setOnClickListener(new View.OnClickListener() {
128
- @Override
129
- public void onClick(View v) {
130
- // 中止
131
- countDown.cancel();
132
- timerText.setText(dataFormat.format(0));
133
- }
134
- });
135
- happyoButton.setOnClickListener(new View.OnClickListener() {
136
- @Override
137
- public void onClick(View v) {
138
- // 中止
139
- countDown.cancel();
140
- timerText.setText(dataFormat.format(0));
141
- }
142
- });
143
125
  }
144
126
 
145
-
146
-
147
127
  }
148
128
 
149
129