質問編集履歴

2

誤字修正、Answer.javaの追加

2021/12/22 13:58

投稿

rott
rott

スコア6

test CHANGED
File without changes
test CHANGED
@@ -308,6 +308,166 @@
308
308
 
309
309
  ```
310
310
 
311
+ Answer.java
312
+
313
+ ```
314
+
315
+ public class Answer extends AppCompatActivity {
316
+
317
+
318
+
319
+ private Button back;
320
+
321
+ private Button next;
322
+
323
+
324
+
325
+ //MainActivityから読み込み
326
+
327
+ Intent intent = getIntent();
328
+
329
+ public int i = intent.getIntExtra("i",0);
330
+
331
+ public int ans = intent.getIntExtra("ans",0);
332
+
333
+ public int count = intent.getIntExtra("count",0);
334
+
335
+ public int backcount = intent.getIntExtra("backcount",0);
336
+
337
+ public int prob = intent.getIntExtra("prob",5);
338
+
339
+
340
+
341
+ @Override
342
+
343
+ protected void onCreate(Bundle savedInstanceState) {
344
+
345
+ super.onCreate(savedInstanceState);
346
+
347
+ setContentView(R.layout.activity_answer);
348
+
349
+
350
+
351
+ getId();
352
+
353
+
354
+
355
+ showAnswer();
356
+
357
+ }
358
+
359
+
360
+
361
+ public void getId(){
362
+
363
+ back = findViewById(R.id.BackButton);
364
+
365
+ next = findViewById(R.id.NextButton);
366
+
367
+ }
368
+
369
+
370
+
371
+ public void showAnswer(){
372
+
373
+
374
+
375
+ ImageView Answer_picture = findViewById(R.id.Answer_picture);
376
+
377
+ AssetManager assets = getResources().getAssets();
378
+
379
+
380
+
381
+ if(ans == 0){
382
+
383
+ //正解時
384
+
385
+ Answer_picture.setImageResource(R.drawable.maru);
386
+
387
+ }else{
388
+
389
+ //不正解
390
+
391
+ Answer_picture.setImageResource(R.drawable.batsu);
392
+
393
+ }
394
+
395
+
396
+
397
+
398
+
399
+ }
400
+
401
+
402
+
403
+ public void onNext(View view){
404
+
405
+
406
+
407
+ if(i == prob-1){
408
+
409
+
410
+
411
+ Intent intent = new Intent(Answer.this,result.class);
412
+
413
+
414
+
415
+ //Resultに送る変数
416
+
417
+ intent.putExtra("count",count);
418
+
419
+ intent.putExtra("backcount",backcount);
420
+
421
+ intent.putExtra("prob",prob);
422
+
423
+
424
+
425
+ startActivity(intent);
426
+
427
+
428
+
429
+ }else{
430
+
431
+ i++;
432
+
433
+
434
+
435
+ Intent intent = new Intent(Answer.this,MainActivity.class);
436
+
437
+
438
+
439
+ //MainActivityに送る変数
440
+
441
+ intent.putExtra("i",i);
442
+
443
+ intent.putExtra("count",count);
444
+
445
+ intent.putExtra("backcount",backcount);
446
+
447
+
448
+
449
+ startActivity(intent);
450
+
451
+ }
452
+
453
+ finish();
454
+
455
+ }
456
+
457
+
458
+
459
+ public void onBack(View view){
460
+
461
+
462
+
463
+ backcount++;
464
+
465
+ finish();
466
+
467
+ }
468
+
469
+ ```
470
+
311
471
 
312
472
 
313
473
  ### 試したこと

1

誤字修正

2021/12/22 13:58

投稿

rott
rott

スコア6

test CHANGED
File without changes
test CHANGED
@@ -86,9 +86,7 @@
86
86
 
87
87
  ### 該当のソースコード
88
88
 
89
-
90
-
91
- startmenu.java
89
+ StartMenu.java
92
90
 
93
91
  ```
94
92
 
@@ -120,7 +118,7 @@
120
118
 
121
119
  ```
122
120
 
123
- mainactivity.java
121
+ MainActivity.java
124
122
 
125
123
  ```
126
124