質問編集履歴
3
activityのjavaに問題があったようなのでそれを残し、xmlファイルを消させていただきました
test
CHANGED
File without changes
|
test
CHANGED
@@ -184,195 +184,93 @@
|
|
184
184
|
|
185
185
|
|
186
186
|
|
187
|
-
2.activity
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
```
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
an
|
230
|
-
|
231
|
-
a
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
app
|
242
|
-
|
243
|
-
a
|
244
|
-
|
245
|
-
app
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
app:layout_constraintStart_toStartOf="parent"
|
276
|
-
|
277
|
-
app:layout_constraintTop_toBottomOf="@+id/editText3" />
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
<Button
|
282
|
-
|
283
|
-
android:id="@+id/button"
|
284
|
-
|
285
|
-
android:layout_width="0dp"
|
286
|
-
|
287
|
-
android:layout_height="wrap_content"
|
288
|
-
|
289
|
-
android:layout_marginBottom="16dp"
|
290
|
-
|
291
|
-
android:layout_marginEnd="16dp"
|
292
|
-
|
293
|
-
android:layout_marginLeft="16dp"
|
294
|
-
|
295
|
-
android:layout_marginRight="16dp"
|
296
|
-
|
297
|
-
android:layout_marginStart="16dp"
|
298
|
-
|
299
|
-
android:onClick="sendMessage"
|
300
|
-
|
301
|
-
android:text="@string/botton_send"
|
302
|
-
|
303
|
-
app:layout_constraintBottom_toBottomOf="parent"
|
304
|
-
|
305
|
-
app:layout_constraintEnd_toEndOf="parent"
|
306
|
-
|
307
|
-
app:layout_constraintStart_toStartOf="parent" />
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
<EditText
|
312
|
-
|
313
|
-
android:id="@+id/editText3"
|
314
|
-
|
315
|
-
android:layout_width="0dp"
|
316
|
-
|
317
|
-
android:layout_height="48dp"
|
318
|
-
|
319
|
-
android:layout_marginEnd="16dp"
|
320
|
-
|
321
|
-
android:layout_marginLeft="16dp"
|
322
|
-
|
323
|
-
android:layout_marginRight="16dp"
|
324
|
-
|
325
|
-
android:layout_marginStart="16dp"
|
326
|
-
|
327
|
-
android:layout_marginTop="16dp"
|
328
|
-
|
329
|
-
android:background="#ffffff"
|
330
|
-
|
331
|
-
android:ems="10"
|
332
|
-
|
333
|
-
android:hint="@string/edit3_hint"
|
334
|
-
|
335
|
-
android:inputType="number"
|
336
|
-
|
337
|
-
app:layout_constraintEnd_toEndOf="parent"
|
338
|
-
|
339
|
-
app:layout_constraintStart_toStartOf="parent"
|
340
|
-
|
341
|
-
app:layout_constraintTop_toBottomOf="@+id/editText" />
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
</android.support.constraint.ConstraintLayout>
|
346
|
-
|
347
|
-
```
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
3.DisplayResultActivity.java
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
![イメージ説明](5adccdaa5f663eff737e3099f18783d2.png)
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
4.activity_display_result.xml
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
![イメージ説明](1111ae02fdcb83f1a4beb011fe44be18.png)
|
364
|
-
|
365
|
-
![イメージ説明](8610ac0f26ef82ba11295b3ba81b0880.png)
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
5.AndroidManifest.xml
|
370
|
-
|
371
|
-
![イメージ説明](692671aec8a87d86e790f578d576b75d.png)
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
文字数が足りないので3,4,5は画像にしております。
|
187
|
+
2.DisplayResultActivity.java
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
```Java
|
192
|
+
|
193
|
+
package com.sample.stringloop;
|
194
|
+
|
195
|
+
|
196
|
+
|
197
|
+
import android.content.Intent;
|
198
|
+
|
199
|
+
import android.support.v7.app.AppCompatActivity;
|
200
|
+
|
201
|
+
import android.os.Bundle;
|
202
|
+
|
203
|
+
import android.widget.TextView;
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
public class DisplayResultActivity extends AppCompatActivity {
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
@Override
|
212
|
+
|
213
|
+
protected void onCreate(Bundle savedInstanceState) {
|
214
|
+
|
215
|
+
super.onCreate(savedInstanceState);
|
216
|
+
|
217
|
+
setContentView(R.layout.activity_display_result);
|
218
|
+
|
219
|
+
|
220
|
+
|
221
|
+
/* 最初にIntentを取得する*/
|
222
|
+
|
223
|
+
Intent intent = getIntent();
|
224
|
+
|
225
|
+
String mojiretsu = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
|
226
|
+
|
227
|
+
int mojisuu = intent.getIntExtra(MainActivity.EXTRA_MESSAGE3,0);
|
228
|
+
|
229
|
+
boolean kaigyo = intent.getBooleanExtra(MainActivity.EXTRA_BOOLEAN, false);
|
230
|
+
|
231
|
+
int kaigyoi = kaigyo ? 1 : 0;
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
/*繰り返し文字列を作成*/
|
236
|
+
|
237
|
+
StringBuilder sb = new StringBuilder();
|
238
|
+
|
239
|
+
while(sb.length() + mojiretsu.length() + kaigyoi <= mojisuu){
|
240
|
+
|
241
|
+
sb.append(mojiretsu);
|
242
|
+
|
243
|
+
if(kaigyo){
|
244
|
+
|
245
|
+
sb.append(mojiretsu);
|
246
|
+
|
247
|
+
}
|
248
|
+
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
|
253
|
+
/*表示*/
|
254
|
+
|
255
|
+
TextView textView3 = findViewById(R.id.textView3);
|
256
|
+
|
257
|
+
TextView textView4 = findViewById(R.id.textView4);
|
258
|
+
|
259
|
+
TextView editText4 = findViewById(R.id.editText4);
|
260
|
+
|
261
|
+
textView3.setText(mojiretsu);
|
262
|
+
|
263
|
+
textView4.setText(mojisuu);
|
264
|
+
|
265
|
+
editText4.setText(new String(sb));
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
}
|
270
|
+
|
271
|
+
```
|
272
|
+
|
273
|
+
|
376
274
|
|
377
275
|
### 試したこと
|
378
276
|
|
2
CatLogに表示されるエラーログを追記し、文字数オーバーにより3,4も画像にさせていただきました
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,19 +12,93 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
書いているときやビルド時のエラーメッセージは特に出
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
15
|
+
書いているときやビルド時のエラーメッセージは特に出ません。
|
16
|
+
|
17
|
+
追記:ADBのLogCatのErrorを表示すると
|
18
|
+
|
19
|
+
実行時に
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
```Log
|
24
|
+
|
25
|
+
08-30 03:58:30.247 6374-6381/? E/zygote: Failed writing handshake bytes (-1 of 14): Broken pipe
|
26
|
+
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
「作成」ボタンクリック時に
|
32
|
+
|
33
|
+
```Log
|
34
|
+
|
35
|
+
08-30 03:58:44.024 6374-6374/com.sample.stringloop E/AndroidRuntime: FATAL EXCEPTION: main
|
36
|
+
|
37
|
+
Process: com.sample.stringloop, PID: 6374
|
38
|
+
|
39
|
+
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sample.stringloop/com.sample.stringloop.DisplayResultActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x64
|
40
|
+
|
41
|
+
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
|
42
|
+
|
43
|
+
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
|
44
|
+
|
45
|
+
at android.app.ActivityThread.-wrap11(Unknown Source:0)
|
46
|
+
|
47
|
+
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
|
48
|
+
|
49
|
+
at android.os.Handler.dispatchMessage(Handler.java:106)
|
50
|
+
|
51
|
+
at android.os.Looper.loop(Looper.java:164)
|
52
|
+
|
53
|
+
at android.app.ActivityThread.main(ActivityThread.java:6494)
|
54
|
+
|
55
|
+
at java.lang.reflect.Method.invoke(Native Method)
|
56
|
+
|
57
|
+
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
|
58
|
+
|
59
|
+
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
|
60
|
+
|
61
|
+
Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x64
|
62
|
+
|
63
|
+
at android.content.res.Resources.getText(Resources.java:339)
|
64
|
+
|
65
|
+
at android.widget.TextView.setText(TextView.java:5496)
|
66
|
+
|
67
|
+
at com.sample.stringloop.DisplayResultActivity.onCreate(DisplayResultActivity.java:36)
|
68
|
+
|
69
|
+
at android.app.Activity.performCreate(Activity.java:7009)
|
70
|
+
|
71
|
+
at android.app.Activity.performCreate(Activity.java:7000)
|
72
|
+
|
73
|
+
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
|
74
|
+
|
75
|
+
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
|
76
|
+
|
77
|
+
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
|
78
|
+
|
79
|
+
at android.app.ActivityThread.-wrap11(Unknown Source:0)
|
80
|
+
|
81
|
+
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
|
82
|
+
|
83
|
+
at android.os.Handler.dispatchMessage(Handler.java:106)
|
84
|
+
|
85
|
+
at android.os.Looper.loop(Looper.java:164)
|
86
|
+
|
87
|
+
at android.app.ActivityThread.main(ActivityThread.java:6494)
|
88
|
+
|
89
|
+
at java.lang.reflect.Method.invoke(Native Method)
|
90
|
+
|
91
|
+
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
|
92
|
+
|
93
|
+
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
```
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
というエラーログが出ました。(無知で本当に申し訳ございません それでも意味が分からないのでご協力お願い致します。)
|
28
102
|
|
29
103
|
### 該当のソースコード
|
30
104
|
|
@@ -278,87 +352,7 @@
|
|
278
352
|
|
279
353
|
|
280
354
|
|
281
|
-
```Java
|
282
|
-
|
283
|
-
package com.sample.stringloop;
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
import android.content.Intent;
|
288
|
-
|
289
|
-
import android.support.v7.app.AppCompatActivity;
|
290
|
-
|
291
|
-
import android.os.Bundle;
|
292
|
-
|
293
|
-
import android.widget.TextView;
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
public class DisplayResultActivity extends AppCompatActivity {
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
@Override
|
302
|
-
|
303
|
-
protected void onCreate(Bundle savedInstanceState) {
|
304
|
-
|
305
|
-
super.onCreate(savedInstanceState);
|
306
|
-
|
307
|
-
|
355
|
+
![イメージ説明](5adccdaa5f663eff737e3099f18783d2.png)
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
/* 最初にIntentを取得する*/
|
312
|
-
|
313
|
-
Intent intent = getIntent();
|
314
|
-
|
315
|
-
String mojiretsu = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
|
316
|
-
|
317
|
-
int mojisuu = intent.getIntExtra(MainActivity.EXTRA_MESSAGE3,0);
|
318
|
-
|
319
|
-
boolean kaigyo = intent.getBooleanExtra(MainActivity.EXTRA_BOOLEAN, false);
|
320
|
-
|
321
|
-
int kaigyoi = kaigyo ? 1 : 0;
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
/*繰り返し文字列を作成*/
|
326
|
-
|
327
|
-
StringBuilder sb = new StringBuilder();
|
328
|
-
|
329
|
-
while(sb.length() + mojiretsu.length() + kaigyoi <= mojisuu){
|
330
|
-
|
331
|
-
sb.append(mojiretsu);
|
332
|
-
|
333
|
-
if(kaigyo){
|
334
|
-
|
335
|
-
sb.append(mojiretsu);
|
336
|
-
|
337
|
-
}
|
338
|
-
|
339
|
-
}
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
/*表示*/
|
344
|
-
|
345
|
-
TextView textView3 = findViewById(R.id.textView3);
|
346
|
-
|
347
|
-
TextView textView4 = findViewById(R.id.textView4);
|
348
|
-
|
349
|
-
TextView editText4 = findViewById(R.id.editText4);
|
350
|
-
|
351
|
-
textView3.setText(mojiretsu);
|
352
|
-
|
353
|
-
textView4.setText(mojisuu);
|
354
|
-
|
355
|
-
editText4.setText(new String(sb));
|
356
|
-
|
357
|
-
}
|
358
|
-
|
359
|
-
}
|
360
|
-
|
361
|
-
```
|
362
356
|
|
363
357
|
|
364
358
|
|
@@ -366,151 +360,19 @@
|
|
366
360
|
|
367
361
|
|
368
362
|
|
369
|
-
```XML
|
370
|
-
|
371
|
-
<?xml version="1.0" encoding="utf-8"?>
|
372
|
-
|
373
|
-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
374
|
-
|
375
|
-
xmlns:app="http://schemas.android.com/apk/res-auto"
|
376
|
-
|
377
|
-
xmlns:tools="http://schemas.android.com/tools"
|
378
|
-
|
379
|
-
android:layout_width="match_parent"
|
380
|
-
|
381
|
-
android:layout_height="match_parent"
|
382
|
-
|
383
|
-
|
363
|
+
![イメージ説明](1111ae02fdcb83f1a4beb011fe44be18.png)
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
364
|
+
|
388
|
-
|
389
|
-
android:id="@+id/textView"
|
390
|
-
|
391
|
-
android:layout_width="wrap_content"
|
392
|
-
|
393
|
-
android:layout_height="wrap_content"
|
394
|
-
|
395
|
-
android:layout_marginLeft="16dp"
|
396
|
-
|
397
|
-
|
365
|
+
![イメージ説明](8610ac0f26ef82ba11295b3ba81b0880.png)
|
398
|
-
|
399
|
-
|
366
|
+
|
400
|
-
|
401
|
-
|
367
|
+
|
402
|
-
|
403
|
-
|
368
|
+
|
404
|
-
|
405
|
-
app:layout_constraintTop_toTopOf="parent" />
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
<TextView
|
410
|
-
|
411
|
-
android:id="@+id/textView2"
|
412
|
-
|
413
|
-
android:layout_width="wrap_content"
|
414
|
-
|
415
|
-
android:layout_height="wrap_content"
|
416
|
-
|
417
|
-
android:layout_marginLeft="16dp"
|
418
|
-
|
419
|
-
android:layout_marginStart="16dp"
|
420
|
-
|
421
|
-
android:layout_marginTop="16dp"
|
422
|
-
|
423
|
-
android:text="@string/view2_message"
|
424
|
-
|
425
|
-
app:layout_constraintStart_toStartOf="parent"
|
426
|
-
|
427
|
-
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
<EditText
|
432
|
-
|
433
|
-
android:id="@+id/editText4"
|
434
|
-
|
435
|
-
android:layout_width="0dp"
|
436
|
-
|
437
|
-
android:layout_height="0dp"
|
438
|
-
|
439
|
-
android:layout_marginBottom="16dp"
|
440
|
-
|
441
|
-
android:layout_marginEnd="16dp"
|
442
|
-
|
443
|
-
android:layout_marginLeft="16dp"
|
444
|
-
|
445
|
-
android:layout_marginRight="16dp"
|
446
|
-
|
447
|
-
android:layout_marginStart="16dp"
|
448
|
-
|
449
|
-
android:layout_marginTop="16dp"
|
450
|
-
|
451
|
-
|
369
|
+
5.AndroidManifest.xml
|
452
|
-
|
453
|
-
|
370
|
+
|
454
|
-
|
455
|
-
android:text="Name"
|
456
|
-
|
457
|
-
app:layout_constraintBottom_toBottomOf="parent"
|
458
|
-
|
459
|
-
app:layout_constraintEnd_toEndOf="parent"
|
460
|
-
|
461
|
-
app:layout_constraintStart_toStartOf="parent"
|
462
|
-
|
463
|
-
app:layout_constraintTop_toBottomOf="@+id/textView2" />
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
<TextView
|
468
|
-
|
469
|
-
android:id="@+id/textView3"
|
470
|
-
|
471
|
-
android:layout_width="wrap_content"
|
472
|
-
|
473
|
-
android:layout_height="wrap_content"
|
474
|
-
|
475
|
-
android:layout_marginLeft="8dp"
|
476
|
-
|
477
|
-
android:layout_marginStart="8dp"
|
478
|
-
|
479
|
-
android:text="TextView"
|
480
|
-
|
481
|
-
app:layout_constraintBaseline_toBaselineOf="@+id/textView"
|
482
|
-
|
483
|
-
app:layout_constraintStart_toEndOf="@+id/textView" />
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
<TextView
|
488
|
-
|
489
|
-
android:id="@+id/textView4"
|
490
|
-
|
491
|
-
android:layout_width="wrap_content"
|
492
|
-
|
493
|
-
android:layout_height="wrap_content"
|
494
|
-
|
495
|
-
android:layout_marginLeft="8dp"
|
496
|
-
|
497
|
-
android:layout_marginStart="8dp"
|
498
|
-
|
499
|
-
android:text="TextView"
|
500
|
-
|
501
|
-
app:layout_constraintBaseline_toBaselineOf="@+id/textView2"
|
502
|
-
|
503
|
-
app:layout_constraintStart_toEndOf="@+id/textView2" />
|
504
|
-
|
505
|
-
</android.support.constraint.ConstraintLayout>
|
506
|
-
|
507
|
-
```
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
371
|
+
![イメージ説明](692671aec8a87d86e790f578d576b75d.png)
|
372
|
+
|
373
|
+
|
374
|
+
|
512
|
-
|
375
|
+
文字数が足りないので3,4,5は画像にしております。
|
513
|
-
|
514
376
|
|
515
377
|
### 試したこと
|
516
378
|
|
1
発生している問題・エラーメッセージについて追記しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,17 @@
|
|
12
12
|
|
13
13
|
|
14
14
|
|
15
|
-
書いているときやビルド時のエラーメッセージは特に出ないのですが、実行してみると
|
15
|
+
書いているときやビルド時のエラーメッセージは特に出ないのですが、実行してみると
|
16
|
+
|
17
|
+
![イメージ説明](677fbbcef1ee757133f5dde76c6a3d6a.png)
|
18
|
+
|
19
|
+
ここで「作成」をクリックすると
|
20
|
+
|
21
|
+
![イメージ説明](63bcdca4268f88b44fb97bb8e6d83977.png)
|
22
|
+
|
23
|
+
このようなログが出てアプリが終了します
|
24
|
+
|
25
|
+
(適当な説明で申し訳ございませんでした)
|
16
26
|
|
17
27
|
|
18
28
|
|