質問編集履歴

1

タイトルの修正

2019/08/14 05:38

投稿

kitarou
kitarou

スコア8

test CHANGED
@@ -1 +1 @@
1
- Navigation drawerの実装について(AndroidStudio ,Kotlin 使用)
1
+ Navigation drawerの実装で、itemのタッチイベントが上手くいきません
test CHANGED
@@ -54,13 +54,13 @@
54
54
 
55
55
  ```
56
56
 
57
-
57
+ ソースコード
58
58
 
59
59
  ### 該当のソースコード
60
60
 
61
61
  -----main.activity.xml---------------------------------------------------------
62
62
 
63
- <android.support.v4.widget.DrawerLayout
63
+ `<android.support.v4.widget.DrawerLayout
64
64
 
65
65
  xmlns:android="http://schemas.android.com/apk/res/android"
66
66
 
@@ -76,11 +76,11 @@
76
76
 
77
77
  android:layout_height="match_parent"
78
78
 
79
- android:background="@color/colorPrimaryDark">
79
+ android:background="@color/colorPrimaryDark">`
80
80
 
81
81
 
82
82
 
83
- <android.support.design.widget.NavigationView
83
+ `<android.support.design.widget.NavigationView
84
84
 
85
85
  android:id="@+id/nav_view"
86
86
 
@@ -100,20 +100,18 @@
100
100
 
101
101
  android:background="@drawable/pic_category_bg">
102
102
 
103
- </android.support.design.widget.NavigationView>
103
+ </android.support.design.widget.NavigationView>`
104
104
 
105
105
 
106
106
 
107
107
  ----navigation_item.xml---------------------------------------------------------
108
108
 
109
- <?xml version="1.0" encoding="utf-8"?>
109
+ `<?xml version="1.0" encoding="utf-8"?>
110
110
 
111
111
  <menu xmlns:app="http://schemas.android.com/apk/res-auto"
112
112
 
113
113
  xmlns:android="http://schemas.android.com/apk/res/android">
114
114
 
115
-
116
-
117
115
  <item
118
116
 
119
117
  android:id="@+id/navigation_home"
@@ -122,18 +120,14 @@
122
120
 
123
121
  android:title="テスト"/>
124
122
 
125
-
126
-
127
123
  <item
128
124
 
129
- android:id="@+id/navigation_dashboard"
125
+ ndroid:id="@+id/navigation_dashboard"
130
126
 
131
127
  android:icon="@drawable/button_category_food"
132
128
 
133
129
  android:title="テスト"/>
134
130
 
135
-
136
-
137
131
  <item
138
132
 
139
133
  android:id="@+id/navigation_notifications"
@@ -144,9 +138,7 @@
144
138
 
145
139
  app:showAsAction="always"/>
146
140
 
147
-
148
-
149
- </menu>
141
+ </menu>`
150
142
 
151
143
 
152
144
 
@@ -160,27 +152,19 @@
160
152
 
161
153
  //ボタン押下でnavigationviewの表示
162
154
 
155
+
156
+
163
- button6.setOnClickListener {
157
+ `button6.setOnClickListener {
164
158
 
165
159
  nav_view.setBackgroundResource(R.drawable.test)
166
160
 
167
-
168
-
169
161
  this.drawer_layout.openDrawer(nav_view)
170
162
 
171
163
  }
172
164
 
173
-
174
-
175
165
   //navigationviewのリスナー設定
176
166
 
177
- nav_view.setNavigationItemSelectedListener(this)
167
+ nav_view.setNavigationItemSelectedListener(this)`
178
-
179
-
180
-
181
-
182
-
183
-
184
168
 
185
169
 
186
170
 
@@ -188,11 +172,7 @@
188
172
 
189
173
 
190
174
 
191
- override fun onNavigationItemSelected(item: android.view.MenuItem): Boolean {
175
+ `override fun onNavigationItemSelected(item: android.view.MenuItem): Boolean {
192
-
193
-
194
-
195
-
196
176
 
197
177
  when (item.itemId) {
198
178
 
@@ -200,43 +180,25 @@
200
180
 
201
181
  Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
202
182
 
203
-
204
-
205
183
  R.id.navigation_dashboard ->
206
184
 
207
185
  Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
208
186
 
209
-
210
-
211
187
  R.id.navigation_notifications ->
212
188
 
213
189
  Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
214
190
 
215
191
  }
216
192
 
217
-
218
-
219
193
  drawer_layout.closeDrawer(Gravity.START)
220
194
 
221
195
  return true
222
196
 
223
-
224
-
225
-
226
-
227
- }
228
-
229
-
230
-
231
-
232
-
233
-
234
-
235
- ```ここに言語名を入力
236
-
237
- ソースコード
238
-
239
- ```
197
+ } `
198
+
199
+
200
+
201
+
240
202
 
241
203
 
242
204