質問編集履歴
1
エラー内容を追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -35,10 +35,12 @@
|
|
35
35
|
val startButton = findViewById<Button>(R.id.startButton)
|
36
36
|
// ボタンを連打したときに何度も処理してしまうのを防ぐため。jobを設定する
|
37
37
|
⭐️val job: Job? = null
|
38
|
+
// エラー内容⇨Unresolved reference: Job
|
38
39
|
startButton.setOnClickListener{
|
39
40
|
// 下記にすることで連打したときに何度も処理されることを防げる。coroutinesが複数起動しなくなるということ。
|
40
41
|
if (job?.isActive == true) return@setOnClickListener
|
41
42
|
job = ⭐️lifecycleScope.launch {
|
43
|
+
// エラー内容⇨Unresolved reference: lifecycleScope
|
42
44
|
val textView = findViewById<TextView>(R.id.textView)
|
43
45
|
var count = 0
|
44
46
|
try {
|
@@ -46,6 +48,8 @@
|
|
46
48
|
textView.text = "${count}秒"
|
47
49
|
count++
|
48
50
|
⭐️delay(1000)
|
51
|
+
// エラー内容⇨Suspend function 'delay' should be called only from a coroutine or another suspend function
|
52
|
+
|
49
53
|
}
|
50
54
|
} finally {
|
51
55
|
textView.text = "停止"
|