質問編集履歴
5
1234
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
![イメージ説明](08691ebb91c17ab7fde8c427fa7e29cd.png)
|
6
|
+
|
7
|
+
|
8
|
+
|
5
9
|
```ここに言語を入力
|
6
10
|
|
7
11
|
◆AndroidManifest.xml
|
4
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
<resources>
|
14
14
|
|
15
|
-
<color name="colorPrimary">#e7
|
15
|
+
<color name="colorPrimary">#e56700</color>
|
16
16
|
|
17
17
|
<color name="colorPrimaryDark">#B35900</color>
|
18
18
|
|
3
ああ
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#追記
|
1
|
+
#追記 該当ソース
|
2
2
|
|
3
3
|
|
4
4
|
|
2
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,313 @@
|
|
1
|
+
#追記
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
```ここに言語を入力
|
6
|
+
|
7
|
+
◆AndroidManifest.xml
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
<?xml version="1.0" encoding="utf-8"?>
|
12
|
+
|
13
|
+
<resources>
|
14
|
+
|
15
|
+
<color name="colorPrimary">#e77700</color>
|
16
|
+
|
17
|
+
<color name="colorPrimaryDark">#B35900</color>
|
18
|
+
|
19
|
+
<color name="colorAccent">#D81B60</color>
|
20
|
+
|
21
|
+
</resources>
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
◆DashboardFragment.kt
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
package com.HOGE.HOGEapprication.ui.dashboard
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
import android.os.Bundle
|
34
|
+
|
35
|
+
import android.view.LayoutInflater
|
36
|
+
|
37
|
+
import android.view.View
|
38
|
+
|
39
|
+
import android.view.ViewGroup
|
40
|
+
|
41
|
+
import android.webkit.WebResourceRequest
|
42
|
+
|
43
|
+
import android.webkit.WebView
|
44
|
+
|
45
|
+
import android.webkit.WebViewClient
|
46
|
+
|
47
|
+
import android.widget.TextView
|
48
|
+
|
49
|
+
import androidx.fragment.app.Fragment
|
50
|
+
|
51
|
+
import androidx.lifecycle.Observer
|
52
|
+
|
53
|
+
import androidx.lifecycle.ViewModelProviders
|
54
|
+
|
55
|
+
import com.HOGE.HOGEapprication.R
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
class DashboardFragment : Fragment() {
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
private lateinit var dashboardViewModel: DashboardViewModel
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
override fun onCreateView(
|
68
|
+
|
69
|
+
inflater: LayoutInflater,
|
70
|
+
|
71
|
+
container: ViewGroup?,
|
72
|
+
|
73
|
+
savedInstanceState: Bundle?
|
74
|
+
|
75
|
+
): View? {
|
76
|
+
|
77
|
+
dashboardViewModel =
|
78
|
+
|
79
|
+
ViewModelProviders.of(this).get(DashboardViewModel::class.java)
|
80
|
+
|
81
|
+
val root = inflater.inflate(R.layout.fragment_dashboard, container, false)
|
82
|
+
|
83
|
+
val textView: TextView = root.findViewById(R.id.text_dashboard)
|
84
|
+
|
85
|
+
dashboardViewModel.text.observe(this, Observer {
|
86
|
+
|
87
|
+
textView.text = it
|
88
|
+
|
89
|
+
})
|
90
|
+
|
91
|
+
/*
|
92
|
+
|
93
|
+
val myWebView: WebView = root.findViewById(R.id.webview_dashboard)
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
myWebView.webViewClient = object : WebViewClient() {
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
/*WebViewで新しいurlに対してloadingが走った時 API Level 24(= Android 7)未満稼働しない可能性あり*/
|
102
|
+
|
103
|
+
override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
|
104
|
+
|
105
|
+
return false // アプリからブラウザに飛ばせない
|
106
|
+
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
myWebView.loadUrl("https://www.google.com")
|
112
|
+
|
113
|
+
*/
|
114
|
+
|
115
|
+
return root
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
}
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
◆DashboardViewModel.kt
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
package com.HOGE.HOGEapprication.ui.dashboard
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
import androidx.lifecycle.LiveData
|
134
|
+
|
135
|
+
import androidx.lifecycle.MutableLiveData
|
136
|
+
|
137
|
+
import androidx.lifecycle.ViewModel
|
138
|
+
|
139
|
+
|
140
|
+
|
141
|
+
class DashboardViewModel : ViewModel() {
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
private val _text = MutableLiveData<String>().apply {
|
146
|
+
|
147
|
+
value = "This is dashboard Fragment"
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
val text: LiveData<String> = _text
|
152
|
+
|
153
|
+
}
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
◆ACTIVITY_MAIN.XML
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
<?xml version="1.0" encoding="utf-8"?>
|
166
|
+
|
167
|
+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
168
|
+
|
169
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
170
|
+
|
171
|
+
android:id="@+id/container"
|
172
|
+
|
173
|
+
android:layout_width="match_parent"
|
174
|
+
|
175
|
+
android:layout_height="match_parent"
|
176
|
+
|
177
|
+
android:paddingTop="?attr/actionBarSize">
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
<WebView
|
182
|
+
|
183
|
+
android:id="@+id/webview"
|
184
|
+
|
185
|
+
android:layout_width="match_parent"
|
186
|
+
|
187
|
+
android:layout_height="match_parent"
|
188
|
+
|
189
|
+
/>
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
<com.google.android.material.bottomnavigation.BottomNavigationView
|
194
|
+
|
195
|
+
android:id="@+id/nav_view"
|
196
|
+
|
197
|
+
android:layout_width="0dp"
|
198
|
+
|
199
|
+
android:layout_height="wrap_content"
|
200
|
+
|
201
|
+
android:layout_marginStart="0dp"
|
202
|
+
|
203
|
+
android:layout_marginEnd="0dp"
|
204
|
+
|
205
|
+
android:background="?android:attr/windowBackground"
|
206
|
+
|
207
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
208
|
+
|
209
|
+
app:layout_constraintLeft_toLeftOf="parent"
|
210
|
+
|
211
|
+
app:layout_constraintRight_toRightOf="parent"
|
212
|
+
|
213
|
+
app:menu="@menu/bottom_nav_menu" />
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
<fragment
|
218
|
+
|
219
|
+
android:id="@+id/nav_host_fragment"
|
220
|
+
|
221
|
+
android:name="androidx.navigation.fragment.NavHostFragment"
|
222
|
+
|
223
|
+
android:layout_width="match_parent"
|
224
|
+
|
225
|
+
android:layout_height="match_parent"
|
226
|
+
|
227
|
+
app:defaultNavHost="true"
|
228
|
+
|
229
|
+
app:layout_constraintBottom_toTopOf="@id/nav_view"
|
230
|
+
|
231
|
+
app:layout_constraintLeft_toLeftOf="parent"
|
232
|
+
|
233
|
+
app:layout_constraintRight_toRightOf="parent"
|
234
|
+
|
235
|
+
app:layout_constraintTop_toTopOf="parent"
|
236
|
+
|
237
|
+
app:navGraph="@navigation/mobile_navigation" />
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
◆FRAGMENT_DASHBOARD.XML
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
<?xml version="1.0" encoding="utf-8"?>
|
254
|
+
|
255
|
+
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
256
|
+
|
257
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
258
|
+
|
259
|
+
android:layout_width="match_parent"
|
260
|
+
|
261
|
+
android:layout_height="match_parent">
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
<TextView
|
266
|
+
|
267
|
+
android:id="@+id/text_dashboard"
|
268
|
+
|
269
|
+
android:layout_width="match_parent"
|
270
|
+
|
271
|
+
android:layout_height="wrap_content"
|
272
|
+
|
273
|
+
android:layout_marginStart="8dp"
|
274
|
+
|
275
|
+
android:layout_marginTop="8dp"
|
276
|
+
|
277
|
+
android:layout_marginEnd="8dp"
|
278
|
+
|
279
|
+
android:textAlignment="center"
|
280
|
+
|
281
|
+
android:textSize="20sp"
|
282
|
+
|
283
|
+
app:layout_constraintEnd_toEndOf="parent"
|
284
|
+
|
285
|
+
app:layout_constraintStart_toStartOf="parent"
|
286
|
+
|
287
|
+
app:layout_constraintTop_toTopOf="parent" />
|
288
|
+
|
289
|
+
|
290
|
+
|
291
|
+
<!-- webページ表示-->
|
292
|
+
|
293
|
+
<WebView
|
294
|
+
|
295
|
+
android:id="@+id/webview_dashboard"
|
296
|
+
|
297
|
+
android:layout_width="match_parent"
|
298
|
+
|
299
|
+
android:layout_height="match_parent"
|
300
|
+
|
301
|
+
/>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
306
|
+
|
307
|
+
```
|
308
|
+
|
309
|
+
|
310
|
+
|
1
311
|
お世話になります。
|
2
312
|
|
3
313
|
アンドロイドスタジオでLOLIPOP API22最小要件対策をしています。WEBVIEWを実行できず質問させて頂きます。
|
1
あ
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
お世話になります。
|
2
2
|
|
3
|
+
アンドロイドスタジオでLOLIPOP API22最小要件対策をしています。WEBVIEWを実行できず質問させて頂きます。
|
4
|
+
|
5
|
+
|
6
|
+
|
3
|
-
|
7
|
+
他apiでは正常に稼働しているのですがwebviewを追加すると、以下エラーが出てしまいます。既にほかのコードはデバッグできており以下コードがエラー原因コードである事は特定できています。以下のコードはもちろん通常のwebviewですのでAPIをあげれば正常に動作しますがapi22ではエラーとなります。
|
4
8
|
|
5
9
|
|
6
10
|
|
@@ -40,4 +44,10 @@
|
|
40
44
|
|
41
45
|
|
42
46
|
|
47
|
+
ためしたこと
|
48
|
+
|
49
|
+
例えばapi29では正常に上記コードが稼働しエラーは発生してませんでした。
|
50
|
+
|
51
|
+
|
52
|
+
|
43
53
|
よろしくお願いします。
|