質問編集履歴

2

コードの追加

2019/05/30 07:29

投稿

uhsi
uhsi

スコア57

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,7 @@
6
6
 
7
7
  http://hakoniwadesign.com/?p=10873
8
8
 
9
- こちらの情報を参考にさせ精させていただきました。
9
+ こちらの情報を参考にさせていただきました。
10
10
 
11
11
 
12
12
 
@@ -163,3 +163,175 @@
163
163
  at dalvik.system.NativeStart.main(Native Method) 
164
164
 
165
165
  ```
166
+
167
+
168
+
169
+ ```xml
170
+
171
+ <?xml version="1.0" encoding="utf-8"?>
172
+
173
+ <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
174
+
175
+ xmlns:app="http://schemas.android.com/apk/res-auto"
176
+
177
+ xmlns:tools="http://schemas.android.com/tools"
178
+
179
+ android:layout_width="match_parent"
180
+
181
+ android:layout_height="match_parent"
182
+
183
+ tools:context=".MainActivity">
184
+
185
+
186
+
187
+ <ImageView
188
+
189
+ android:scaleType="centerCrop"
190
+
191
+ android:src="@drawable/back"
192
+
193
+ android:layout_width="match_parent"
194
+
195
+ android:layout_height="match_parent" />
196
+
197
+
198
+
199
+ <ImageView
200
+
201
+ android:id="@+id/egg"
202
+
203
+ android:onClick="onEgg"
204
+
205
+ android:layout_alignParentBottom="true"
206
+
207
+ android:layout_centerHorizontal="true"
208
+
209
+ android:src="@drawable/egg0"
210
+
211
+ android:layout_width="wrap_content"
212
+
213
+ android:layout_height="wrap_content" />
214
+
215
+
216
+
217
+ </RelativeLayout>
218
+
219
+ ```
220
+
221
+
222
+
223
+ ```java
224
+
225
+ package com.example.myegg;
226
+
227
+
228
+
229
+ import android.os.Bundle;
230
+
231
+ import android.support.v7.app.AppCompatActivity;
232
+
233
+ import android.view.View;
234
+
235
+ import android.widget.ImageView;
236
+
237
+
238
+
239
+ import java.util.Random;
240
+
241
+
242
+
243
+ public class MainActivity extends AppCompatActivity {
244
+
245
+
246
+
247
+ // 準備
248
+
249
+ int count;
250
+
251
+ int answer;
252
+
253
+
254
+
255
+ @Override
256
+
257
+ protected void onCreate(Bundle savedInstanceState) {
258
+
259
+ super.onCreate(savedInstanceState);
260
+
261
+ setContentView(R.layout.activity_main);
262
+
263
+
264
+
265
+ // 初期化
266
+
267
+ count = 0;
268
+
269
+ answer = new Random().nextInt(5);
270
+
271
+ }
272
+
273
+
274
+
275
+ // 画像をタップ
276
+
277
+ public void onEgg( View v){
278
+
279
+ count++;
280
+
281
+ if( count >2 ) {
282
+
283
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.egg1);
284
+
285
+ }
286
+
287
+ if( count >4 ) {
288
+
289
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.egg2);
290
+
291
+ }
292
+
293
+ if( count > 6 ) {
294
+
295
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.egg3);
296
+
297
+ }
298
+
299
+ if( count > 8 ) {
300
+
301
+ if( answer == 0 ) {
302
+
303
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.egga);
304
+
305
+ }
306
+
307
+ if( answer == 1 ) {
308
+
309
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.eggb);
310
+
311
+ }
312
+
313
+ if( answer == 2 ) {
314
+
315
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.eggc);
316
+
317
+ }
318
+
319
+ if( answer == 3 ) {
320
+
321
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.eggd);
322
+
323
+ }
324
+
325
+ if( answer == 4 ) {
326
+
327
+ ((ImageView)findViewById(R.id.egg)).setImageResource(R.drawable.egge);
328
+
329
+ }
330
+
331
+ }
332
+
333
+ }
334
+
335
+ }
336
+
337
+ ```

1

エラーコードの追加

2019/05/30 07:29

投稿

uhsi
uhsi

スコア57

test CHANGED
File without changes
test CHANGED
@@ -1,3 +1,165 @@
1
1
  ImageViewを使用した場合のみ実機でのテストの際に「問題が発生しました」とデバイスに表示されてプログラムを開くことができません。
2
2
 
3
3
  エミュレーターを使用した場合はエラーが発生しません。
4
+
5
+
6
+
7
+ http://hakoniwadesign.com/?p=10873
8
+
9
+ こちらの情報を参考にさせ精させていただきました。
10
+
11
+
12
+
13
+ ```LogCat
14
+
15
+ 05-29 16:39:01.993 2177-2177/com.example.myegg E/dalvikvm: Could not find class 'android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper', referenced from method android.support.v4.view.ViewCompat.addOnUnhandledKeyEventListener
16
+
17
+ 05-29 16:39:01.995 2177-2177/com.example.myegg E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.view.ViewCompat.dispatchApplyWindowInsets
18
+
19
+ 05-29 16:39:02.009 2177-2177/com.example.myegg E/dalvikvm: Could not find class 'android.view.WindowInsets', referenced from method android.support.v4.view.ViewCompat.onApplyWindowInsets
20
+
21
+ 05-29 16:39:02.010 2177-2177/com.example.myegg E/dalvikvm: Could not find class 'android.view.View$OnUnhandledKeyEventListener', referenced from method android.support.v4.view.ViewCompat.removeOnUnhandledKeyEventListener
22
+
23
+ 05-29 16:39:02.017 2177-2177/com.example.myegg E/dalvikvm: Could not find class 'android.support.v4.view.ViewCompat$1', referenced from method android.support.v4.view.ViewCompat.setOnApplyWindowInsetsListener
24
+
25
+ 05-29 16:39:02.035 2177-2177/com.example.myegg E/dalvikvm: Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method android.support.v7.widget.AppCompatImageHelper.hasOverlappingRendering
26
+
27
+ 05-29 16:39:02.060 2177-2177/com.example.myegg E/AndroidRuntime: FATAL EXCEPTION: main
28
+
29
+ java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myegg/com.example.myegg.MainActivity}: android.view.InflateException: Binary XML file line #9: Error inflating class ImageView
30
+
31
+ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2234)
32
+
33
+ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2287)
34
+
35
+ at android.app.ActivityThread.access$600(ActivityThread.java:183)
36
+
37
+ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1288)
38
+
39
+ at android.os.Handler.dispatchMessage(Handler.java:99)
40
+
41
+ at android.os.Looper.loop(Looper.java:137)
42
+
43
+ at android.app.ActivityThread.main(ActivityThread.java:5252)
44
+
45
+ at java.lang.reflect.Method.invokeNative(Native Method)
46
+
47
+ at java.lang.reflect.Method.invoke(Method.java:511)
48
+
49
+ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:798)
50
+
51
+ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565)
52
+
53
+ at dalvik.system.NativeStart.main(Native Method)
54
+
55
+ Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class ImageView
56
+
57
+ at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
58
+
59
+ at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
60
+
61
+ at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
62
+
63
+ at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
64
+
65
+ at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
66
+
67
+ at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
68
+
69
+ at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
70
+
71
+ at com.example.myegg.MainActivity.onCreate(MainActivity.java:19)
72
+
73
+ at android.app.Activity.performCreate(Activity.java:5146)
74
+
75
+ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092)
76
+
77
+ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198)
78
+
79
+ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2287) 
80
+
81
+ at android.app.ActivityThread.access$600(ActivityThread.java:183) 
82
+
83
+ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1288) 
84
+
85
+ at android.os.Handler.dispatchMessage(Handler.java:99) 
86
+
87
+ at android.os.Looper.loop(Looper.java:137) 
88
+
89
+ at android.app.ActivityThread.main(ActivityThread.java:5252) 
90
+
91
+ at java.lang.reflect.Method.invokeNative(Native Method) 
92
+
93
+ at java.lang.reflect.Method.invoke(Method.java:511) 
94
+
95
+ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:798) 
96
+
97
+ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565) 
98
+
99
+ at dalvik.system.NativeStart.main(Native Method) 
100
+
101
+ Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060055 a=-1 r=0x7f060055}
102
+
103
+ at android.content.res.Resources.loadDrawable(Resources.java:1927)
104
+
105
+ at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
106
+
107
+ at android.widget.ImageView.<init>(ImageView.java:120)
108
+
109
+ at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:72)
110
+
111
+ at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:68)
112
+
113
+ at android.support.v7.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:182)
114
+
115
+ at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:106)
116
+
117
+ at android.support.v7.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
118
+
119
+ at android.support.v7.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
120
+
121
+ at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:675)
122
+
123
+ at android.view.LayoutInflater.rInflate(LayoutInflater.java:746) 
124
+
125
+ at android.view.LayoutInflater.inflate(LayoutInflater.java:489) 
126
+
127
+ at android.view.LayoutInflater.inflate(LayoutInflater.java:396) 
128
+
129
+ at android.view.LayoutInflater.inflate(LayoutInflater.java:352) 
130
+
131
+ at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469) 
132
+
133
+ at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140) 
134
+
135
+ at com.example.myegg.MainActivity.onCreate(MainActivity.java:19) 
136
+
137
+ at android.app.Activity.performCreate(Activity.java:5146) 
138
+
139
+ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1092) 
140
+
141
+ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2198) 
142
+
143
+ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2287) 
144
+
145
+ at android.app.ActivityThread.access$600(ActivityThread.java:183) 
146
+
147
+ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1288) 
148
+
149
+ at android.os.Handler.dispatchMessage(Handler.java:99) 
150
+
151
+ at android.os.Looper.loop(Looper.java:137) 
152
+
153
+ at android.app.ActivityThread.main(ActivityThread.java:5252) 
154
+
155
+ at java.lang.reflect.Method.invokeNative(Native Method) 
156
+
157
+ at java.lang.reflect.Method.invoke(Method.java:511) 
158
+
159
+ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:798) 
160
+
161
+ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:565) 
162
+
163
+ at dalvik.system.NativeStart.main(Native Method) 
164
+
165
+ ```