質問編集履歴
1
画像でなくコードを使って説明した
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,16 +6,71 @@
|
|
6
6
|
一体何が原因なのでしょうか。
|
7
7
|
|
8
8
|
|
9
|
-
### 問題のコード
|
10
9
|
|
10
|
+
### 該当するソースコード
|
11
|
-
MainFragment.kt
|
11
|
+
```MainFragment.kt
|
12
|
-
|
12
|
+
package com.example.todo
|
13
13
|
|
14
|
+
import android.os.Bundle
|
15
|
+
import android.view.View
|
16
|
+
import androidx.fragment.app.Fragment
|
17
|
+
import androidx.fragment.app.FragmentContainer
|
18
|
+
import androidx.fragment.app.viewModels
|
19
|
+
import androidx.navigation.Navigation.findNavController
|
20
|
+
import androidx.navigation.fragment.findNavController
|
21
|
+
import com.example.todo.databinding.MainFragmentBinding
|
22
|
+
import dagger.hilt.android.AndroidEntryPoint
|
14
23
|
|
15
|
-
main_fragment.xml
|
16
|
-

|
17
24
|
|
25
|
+
@AndroidEntryPoint
|
26
|
+
class MainFragment: Fragment(R.layout.main_fragment) {
|
27
|
+
private val vm: MainViewMotel by viewModels()
|
28
|
+
|
29
|
+
// ここから下を追加
|
30
|
+
private var _binding: MainFragmentBinding? = null
|
31
|
+
private val binding: MainFragmentBinding get() = _binding!!
|
32
|
+
|
33
|
+
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
34
|
+
super.onViewCreated(view, savedInstanceState)
|
35
|
+
this._binding = MainFragmentBinding.bind(view)
|
36
|
+
|
37
|
+
binding.fab.setOnClickListener {
|
38
|
+
findNavController().navigate(R.id.action_mainFragment2_to_createtodoFragment3)
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
override fun onDestroyView() {
|
44
|
+
super.onDestroyView()
|
45
|
+
this._binding = null
|
46
|
+
}
|
47
|
+
}
|
48
|
+
```
|
49
|
+
|
50
|
+
|
51
|
+
```main_fragment.xml
|
52
|
+
<?xml version="1.0" encoding="utf-8"?>
|
53
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
54
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
55
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
56
|
+
xmlns:tools="http://schemas.android.com/tools"
|
57
|
+
android:layout_width="match_parent"
|
58
|
+
android:layout_height="match_parent">
|
59
|
+
|
60
|
+
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
61
|
+
android:id="@+id/fab"
|
62
|
+
android:layout_width="wrap_content"
|
63
|
+
android:layout_height="wrap_content"
|
64
|
+
android:layout_marginEnd="16dp"
|
65
|
+
android:layout_marginRight="16dp"
|
66
|
+
android:layout_marginBottom="16dp"
|
67
|
+
android:clickable="true"
|
68
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
69
|
+
app:layout_constraintEnd_toEndOf="parent"
|
70
|
+
app:srcCompat="@drawable/ic_baseline_add_24"
|
71
|
+
tools:ignore="VectorDrawableCompat" />
|
72
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
73
|
+
```
|
74
|
+
|
18
75
|
仮想デバイス
|
19
|
-

|
20
|
-
|
21
|
-
ちなみにM1Macではないです。
|