質問編集履歴
2
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -382,6 +382,30 @@
|
|
382
382
|
|
383
383
|
|
384
384
|
|
385
|
+
<ImageView
|
386
|
+
|
387
|
+
android:id="@+id/reminderMorningButton"
|
388
|
+
|
389
|
+
android:layout_width="91dp"
|
390
|
+
|
391
|
+
android:layout_height="91dp"
|
392
|
+
|
393
|
+
android:background="@drawable/image_view_maru"
|
394
|
+
|
395
|
+
android:scaleType="fitCenter"
|
396
|
+
|
397
|
+
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
|
398
|
+
|
399
|
+
app:layout_constraintEnd_toEndOf="parent"
|
400
|
+
|
401
|
+
app:layout_constraintStart_toEndOf="@+id/reminderCustomButton"
|
402
|
+
|
403
|
+
app:layout_constraintTop_toBottomOf="@+id/textView"
|
404
|
+
|
405
|
+
app:srcCompat="@drawable/ic_wb_sunny_black_24dp" />
|
406
|
+
|
407
|
+
|
408
|
+
|
385
409
|
<ImageButton
|
386
410
|
|
387
411
|
android:id="@+id/reminderCustomButton"
|
@@ -516,38 +540,8 @@
|
|
516
540
|
|
517
541
|
|
518
542
|
|
519
|
-
<ImageView
|
520
|
-
|
521
|
-
android:id="@+id/reminderMorningButton"
|
522
|
-
|
523
|
-
android:layout_width="91dp"
|
524
|
-
|
525
|
-
android:layout_height="91dp"
|
526
|
-
|
527
|
-
android:background="@drawable/image_view_maru"
|
528
|
-
|
529
|
-
android:scaleType="fitCenter"
|
530
|
-
|
531
|
-
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
|
532
|
-
|
533
|
-
app:layout_constraintEnd_toEndOf="parent"
|
534
|
-
|
535
|
-
app:layout_constraintStart_toEndOf="@+id/reminderCustomButton"
|
536
|
-
|
537
|
-
app:layout_constraintTop_toBottomOf="@+id/textView"
|
538
|
-
|
539
|
-
app:srcCompat="@drawable/ic_wb_sunny_black_24dp" />
|
540
|
-
|
541
|
-
|
542
|
-
|
543
543
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
544
544
|
|
545
|
-
|
546
|
-
|
547
|
-
</androidx.constraintlayout.widget.ConstraintLayout>
|
548
|
-
|
549
|
-
|
550
|
-
|
551
545
|
```
|
552
546
|
|
553
547
|
画面デザイン
|
1
誤字、マークダウンの修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,9 +6,69 @@
|
|
6
6
|
|
7
7
|
##問題
|
8
8
|
|
9
|
-
reminderButton.setOnClickListenerでダイアログのインスタンスを取得した後、dialog.
|
10
|
-
|
11
|
-
|
9
|
+
TaskAddActivityでreminderButton.setOnClickListenerでダイアログのインスタンスを取得した後、dialog.reminderMorningButton.visibility = View.GONEで現在時刻に合わせてボタンを非表示にするという処理を書いていますが、そこでjava.lang.IllegalStateException: dialog.reminderMorningButton must not be nullとなり強制終了してしまいます。
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
TaskAddActivity
|
14
|
+
|
15
|
+
```kotlin
|
16
|
+
|
17
|
+
class TaskAddActivity : AppCompatActivity(), ReminderDialog.Listener{
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
override fun reminderUp(date: Date) {
|
22
|
+
|
23
|
+
val calendar = Calendar.getInstance()
|
24
|
+
|
25
|
+
calendar.time = date
|
26
|
+
|
27
|
+
setAlarmManager(calendar)
|
28
|
+
|
29
|
+
Toast.makeText(
|
30
|
+
|
31
|
+
this, "リマインダーをセット",
|
32
|
+
|
33
|
+
Toast.LENGTH_SHORT
|
34
|
+
|
35
|
+
).show()
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
private lateinit var realm: Realm
|
40
|
+
|
41
|
+
var taskId:Long? = null
|
42
|
+
|
43
|
+
private var taskTitle:String? = null
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
override fun onCreate(savedInstanceState: Bundle?) {
|
48
|
+
|
49
|
+
super.onCreate(savedInstanceState)
|
50
|
+
|
51
|
+
setContentView(R.layout.activity_task_add)
|
52
|
+
|
53
|
+
realm = Realm.getDefaultInstance()
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
taskId = intent?.getLongExtra("task_id", -1L)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
val task = realm.where<Task>().equalTo("id", taskId).findFirst()
|
62
|
+
|
63
|
+
titleEdit.setText(task?.title)
|
64
|
+
|
65
|
+
taskEditText.setText(task?.detail)
|
66
|
+
|
67
|
+
taskTitle = task?.title
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
12
72
|
|
13
73
|
//リマインダーダイアログを呼び出す
|
14
74
|
|
@@ -16,31 +76,37 @@
|
|
16
76
|
|
17
77
|
var dialog = ReminderDialog()
|
18
78
|
|
19
|
-
|
79
|
+
val now = Calendar.getInstance()
|
20
80
|
|
21
81
|
//時刻が夜の6時より前だったら太陽ボタンを消す
|
22
82
|
|
23
83
|
if(now.get(Calendar.HOUR) <= 18 && now.get(Calendar.HOUR) >= 6){
|
24
84
|
|
25
|
-
dialog.
|
85
|
+
dialog.reminderMorningButton.visibility = View.GONE
|
26
86
|
|
27
87
|
}else{
|
28
88
|
|
29
89
|
dialog.reminderNightButton.visibility = View.GONE
|
30
90
|
|
31
|
-
}
|
91
|
+
}
|
32
92
|
|
33
93
|
dialog.show(supportFragmentManager, "alert_dialog")
|
34
94
|
|
35
95
|
}
|
36
96
|
|
97
|
+
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
37
103
|
```
|
38
104
|
|
39
105
|
|
40
106
|
|
41
|
-
|
42
|
-
|
43
|
-
|
107
|
+
ReminderDialog
|
108
|
+
|
109
|
+
```kotlin
|
44
110
|
|
45
111
|
class ReminderDialog : DialogFragment(),
|
46
112
|
|
@@ -292,7 +358,9 @@
|
|
292
358
|
|
293
359
|
```
|
294
360
|
|
295
|
-
|
361
|
+
reminder_layout.xml
|
362
|
+
|
363
|
+
```xml
|
296
364
|
|
297
365
|
<?xml version="1.0" encoding="utf-8"?>
|
298
366
|
|
@@ -450,7 +518,7 @@
|
|
450
518
|
|
451
519
|
<ImageView
|
452
520
|
|
453
|
-
android:id="@+id/reminderMorin
|
521
|
+
android:id="@+id/reminderMorningButton"
|
454
522
|
|
455
523
|
android:layout_width="91dp"
|
456
524
|
|
@@ -476,4 +544,12 @@
|
|
476
544
|
|
477
545
|
|
478
546
|
|
547
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
548
|
+
|
549
|
+
|
550
|
+
|
479
551
|
```
|
552
|
+
|
553
|
+
画面デザイン
|
554
|
+
|
555
|
+
![イメージ説明](6f06729cd12d9ed3cf791e782609a06e.jpeg)
|