質問編集履歴

2

activity_main.xmlのコード追加

2019/03/15 15:23

投稿

kurus
kurus

スコア14

test CHANGED
File without changes
test CHANGED
@@ -24,445 +24,117 @@
24
24
 
25
25
  ### 該当のソースコード
26
26
 
27
+ styles.xml
28
+
29
+ ```
30
+
31
+ <resources>
27
32
 
28
33
 
34
+
35
+ <!-- Base application theme. -->
36
+
37
+ <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
38
+
39
+ <!-- Customize your theme here. -->
40
+
41
+ <item name="colorPrimary">@color/colorPrimary</item>
42
+
43
+ <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
44
+
45
+ <item name="colorAccent">@color/colorAccent</item>
46
+
47
+ </style>
48
+
49
+
50
+
51
+ </resources>
52
+
53
+
54
+
55
+ ```
56
+
57
+
58
+
29
- activity_main.xml
59
+ AndroidManifest.xml
30
60
 
31
61
  ```
32
62
 
33
63
  <?xml version="1.0" encoding="utf-8"?>
34
64
 
35
- <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
65
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
36
66
 
37
- xmlns:app="http://schemas.android.com/apk/res-auto"
38
-
39
- xmlns:tools="http://schemas.android.com/tools"
40
-
41
- android:layout_width="match_parent"
42
-
43
- android:layout_height="match_parent"
44
-
45
- tools:context=".MainActivity">
67
+ package="com.kurus.calculator">
46
68
 
47
69
 
48
70
 
49
- <LinearLayout
71
+ <application
50
72
 
51
- android:layout_width="395dp"
73
+ android:allowBackup="true"
52
74
 
53
- android:layout_height="715dp"
75
+ android:icon="@mipmap/ic_launcher"
54
76
 
55
- android:layout_marginStart="8dp"
77
+ android:label="@string/app_name"
56
78
 
57
- android:layout_marginLeft="8dp"
79
+ android:roundIcon="@mipmap/ic_launcher_round"
58
80
 
59
- android:layout_marginTop="8dp"
81
+ android:supportsRtl="true"
60
82
 
61
- android:layout_marginEnd="8dp"
83
+ android:theme="@style/AppTheme">
62
84
 
63
- android:layout_marginRight="8dp"
85
+ <activity android:name=".MainActivity">
64
86
 
65
- android:layout_marginBottom="8dp"
87
+ <intent-filter>
66
88
 
67
- android:orientation="vertical"
68
-
69
- app:layout_constraintBottom_toBottomOf="parent"
70
-
71
- app:layout_constraintEnd_toEndOf="parent"
72
-
73
- app:layout_constraintHorizontal_bias="0.0"
74
-
75
- app:layout_constraintStart_toStartOf="parent"
76
-
77
- app:layout_constraintTop_toTopOf="parent">
89
+ <action android:name="android.intent.action.MAIN" />
78
90
 
79
91
 
80
92
 
81
- <TextView
93
+ <category android:name="android.intent.category.LAUNCHER" />
82
94
 
83
- android:id="@+id/txtStatus"
95
+ </intent-filter>
84
96
 
85
- android:layout_width="match_parent"
97
+ </activity>
86
98
 
87
- android:layout_height="20dp"
88
-
89
- android:gravity="right|center_vertical"
90
-
91
- android:textSize="18sp" />
99
+ </application>
92
100
 
93
101
 
94
102
 
95
- <TextView
103
+ </manifest>
96
104
 
97
- android:id="@+id/txtAnswer"
105
+ ```
98
106
 
99
- android:layout_width="match_parent"
107
+ MainActivity.java
100
108
 
101
- android:layout_height="wrap_content"
109
+ ```
102
110
 
103
- android:layout_weight="2"
104
-
105
- android:gravity="right|center_vertical"
106
-
107
- android:padding="16dp"
108
-
109
- android:text="0"
111
+ package com.kurus.calculator;
110
-
111
- android:textSize="70sp" />
112
112
 
113
113
 
114
114
 
115
- <LinearLayout
115
+ import android.os.Bundle;
116
116
 
117
- android:layout_width="match_parent"
117
+ import android.support.v7.app.AppCompatActivity;
118
-
119
- android:layout_height="wrap_content"
120
-
121
- android:layout_weight="1"
122
-
123
- android:orientation="horizontal">
124
118
 
125
119
 
126
120
 
127
- <Button
128
-
129
- android:id="@+id/btnSeven"
130
-
131
- android:layout_width="wrap_content"
121
+ public class MainActivity extends AppCompatActivity {
132
-
133
- android:layout_height="match_parent"
134
-
135
- android:layout_weight="1"
136
-
137
- android:onClick="buttonIsClicked"
138
-
139
- android:text="7"
140
-
141
- android:textSize="46sp" />
142
122
 
143
123
 
144
124
 
145
- <Button
125
+ @Override
146
126
 
147
- android:id="@+id/btnEight"
127
+ protected void onCreate(Bundle savedInstanceState) {
148
128
 
149
- android:layout_width="wrap_content"
129
+ super.onCreate(savedInstanceState);
150
130
 
151
- android:layout_height="match_parent"
152
-
153
- android:layout_weight="1"
154
-
155
- android:onClick="buttonIsClicked"
156
-
157
- android:text="8"
158
-
159
- android:textSize="46sp" />
131
+ setContentView(R.layout.activity_main);
160
132
 
161
133
 
162
134
 
163
- <Button
135
+ }
164
136
 
165
- android:id="@+id/btnNine"
166
-
167
- android:layout_width="wrap_content"
168
-
169
- android:layout_height="match_parent"
170
-
171
- android:layout_weight="1"
172
-
173
- android:onClick="buttonIsClicked"
174
-
175
- android:text="9"
176
-
177
- android:textSize="46sp" />
178
-
179
-
180
-
181
- <Button
137
+ }
182
-
183
- android:id="@+id/btnDivision"
184
-
185
- android:layout_width="wrap_content"
186
-
187
- android:layout_height="match_parent"
188
-
189
- android:layout_weight="1"
190
-
191
- android:onClick="buttonIsClicked"
192
-
193
- android:text="÷"
194
-
195
- android:textSize="46sp" />
196
-
197
- </LinearLayout>
198
-
199
-
200
-
201
- <LinearLayout
202
-
203
- android:layout_width="match_parent"
204
-
205
- android:layout_height="wrap_content"
206
-
207
- android:layout_weight="1"
208
-
209
- android:orientation="horizontal">
210
-
211
-
212
-
213
- <Button
214
-
215
- android:id="@+id/btnFour"
216
-
217
- android:layout_width="wrap_content"
218
-
219
- android:layout_height="match_parent"
220
-
221
- android:layout_weight="1"
222
-
223
- android:onClick="buttonIsClicked"
224
-
225
- android:text="4"
226
-
227
- android:textSize="46sp" />
228
-
229
-
230
-
231
- <Button
232
-
233
- android:id="@+id/btnFive"
234
-
235
- android:layout_width="wrap_content"
236
-
237
- android:layout_height="match_parent"
238
-
239
- android:layout_weight="1"
240
-
241
- android:onClick="buttonIsClicked"
242
-
243
- android:text="5"
244
-
245
- android:textSize="46sp" />
246
-
247
-
248
-
249
- <Button
250
-
251
- android:id="@+id/btnSix"
252
-
253
- android:layout_width="wrap_content"
254
-
255
- android:layout_height="match_parent"
256
-
257
- android:layout_weight="1"
258
-
259
- android:onClick="buttonIsClicked"
260
-
261
- android:text="6"
262
-
263
- android:textSize="46sp" />
264
-
265
-
266
-
267
- <Button
268
-
269
- android:id="@+id/btnMultiplation"
270
-
271
- android:layout_width="wrap_content"
272
-
273
- android:layout_height="match_parent"
274
-
275
- android:layout_weight="1"
276
-
277
- android:onClick="buttonIsClicked"
278
-
279
- android:text="×"
280
-
281
- android:textSize="46sp" />
282
-
283
- </LinearLayout>
284
-
285
-
286
-
287
- <LinearLayout
288
-
289
- android:layout_width="match_parent"
290
-
291
- android:layout_height="wrap_content"
292
-
293
- android:layout_weight="1"
294
-
295
- android:orientation="horizontal">
296
-
297
-
298
-
299
- <Button
300
-
301
- android:id="@+id/btnOne"
302
-
303
- android:layout_width="wrap_content"
304
-
305
- android:layout_height="match_parent"
306
-
307
- android:layout_weight="1"
308
-
309
- android:onClick="buttonIsClicked"
310
-
311
- android:text="1"
312
-
313
- android:textSize="46sp" />
314
-
315
-
316
-
317
- <Button
318
-
319
- android:id="@+id/btnTwo"
320
-
321
- android:layout_width="wrap_content"
322
-
323
- android:layout_height="match_parent"
324
-
325
- android:layout_weight="1"
326
-
327
- android:onClick="buttonIsClicked"
328
-
329
- android:text="2"
330
-
331
- android:textSize="46sp" />
332
-
333
-
334
-
335
- <Button
336
-
337
- android:id="@+id/btnThree"
338
-
339
- android:layout_width="wrap_content"
340
-
341
- android:layout_height="match_parent"
342
-
343
- android:layout_weight="1"
344
-
345
- android:onClick="buttonIsClicked"
346
-
347
- android:text="3"
348
-
349
- android:textSize="46sp" />
350
-
351
-
352
-
353
- <Button
354
-
355
- android:id="@+id/btnMinus"
356
-
357
- android:layout_width="wrap_content"
358
-
359
- android:layout_height="match_parent"
360
-
361
- android:layout_weight="1"
362
-
363
- android:onClick="buttonIsClicked"
364
-
365
- android:text="-"
366
-
367
- android:textSize="46sp" />
368
-
369
- </LinearLayout>
370
-
371
-
372
-
373
- <LinearLayout
374
-
375
- android:layout_width="match_parent"
376
-
377
- android:layout_height="wrap_content"
378
-
379
- android:layout_weight="1"
380
-
381
- android:orientation="horizontal">
382
-
383
-
384
-
385
- <Button
386
-
387
- android:id="@+id/btnClear"
388
-
389
- android:layout_width="wrap_content"
390
-
391
- android:layout_height="match_parent"
392
-
393
- android:layout_weight="1"
394
-
395
- android:onClick="buttonIsClicked"
396
-
397
- android:text="C"
398
-
399
- android:textSize="46sp" />
400
-
401
-
402
-
403
- <Button
404
-
405
- android:id="@+id/btnZero"
406
-
407
- android:layout_width="wrap_content"
408
-
409
- android:layout_height="match_parent"
410
-
411
- android:layout_weight="1"
412
-
413
- android:onClick="buttonIsClicked"
414
-
415
- android:text="0"
416
-
417
- android:textSize="46sp" />
418
-
419
-
420
-
421
- <Button
422
-
423
- android:id="@+id/btnEqual"
424
-
425
- android:layout_width="wrap_content"
426
-
427
- android:layout_height="match_parent"
428
-
429
- android:layout_weight="1"
430
-
431
- android:onClick="buttonIsClicked"
432
-
433
- android:text="="
434
-
435
- android:textSize="46sp" />
436
-
437
-
438
-
439
- <Button
440
-
441
- android:id="@+id/btnPlus"
442
-
443
- android:layout_width="wrap_content"
444
-
445
- android:layout_height="match_parent"
446
-
447
- android:layout_weight="1"
448
-
449
- android:onClick="buttonIsClicked"
450
-
451
- android:text="+"
452
-
453
- android:textSize="46sp" />
454
-
455
- </LinearLayout>
456
-
457
-
458
-
459
-
460
-
461
- </LinearLayout>
462
-
463
-
464
-
465
- </android.support.constraint.ConstraintLayout>
466
138
 
467
139
  ```
468
140
 

1

activity_main.xmlのコード追加

2019/03/15 15:23

投稿

kurus
kurus

スコア14

test CHANGED
File without changes
test CHANGED
@@ -24,120 +24,448 @@
24
24
 
25
25
  ### 該当のソースコード
26
26
 
27
+
28
+
27
- styles.xml
29
+ activity_main.xml
28
30
 
29
31
  ```
30
32
 
31
- <resources>
32
-
33
-
34
-
35
- <!-- Base application theme. -->
36
-
37
- <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
38
-
39
- <!-- Customize your theme here. -->
40
-
41
- <item name="colorPrimary">@color/colorPrimary</item>
42
-
43
- <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
44
-
45
- <item name="colorAccent">@color/colorAccent</item>
46
-
47
- </style>
48
-
49
-
50
-
51
- </resources>
52
-
53
-
33
+ <?xml version="1.0" encoding="utf-8"?>
34
+
35
+ <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
36
+
37
+ xmlns:app="http://schemas.android.com/apk/res-auto"
38
+
39
+ xmlns:tools="http://schemas.android.com/tools"
40
+
41
+ android:layout_width="match_parent"
42
+
43
+ android:layout_height="match_parent"
44
+
45
+ tools:context=".MainActivity">
46
+
47
+
48
+
49
+ <LinearLayout
50
+
51
+ android:layout_width="395dp"
52
+
53
+ android:layout_height="715dp"
54
+
55
+ android:layout_marginStart="8dp"
56
+
57
+ android:layout_marginLeft="8dp"
58
+
59
+ android:layout_marginTop="8dp"
60
+
61
+ android:layout_marginEnd="8dp"
62
+
63
+ android:layout_marginRight="8dp"
64
+
65
+ android:layout_marginBottom="8dp"
66
+
67
+ android:orientation="vertical"
68
+
69
+ app:layout_constraintBottom_toBottomOf="parent"
70
+
71
+ app:layout_constraintEnd_toEndOf="parent"
72
+
73
+ app:layout_constraintHorizontal_bias="0.0"
74
+
75
+ app:layout_constraintStart_toStartOf="parent"
76
+
77
+ app:layout_constraintTop_toTopOf="parent">
78
+
79
+
80
+
81
+ <TextView
82
+
83
+ android:id="@+id/txtStatus"
84
+
85
+ android:layout_width="match_parent"
86
+
87
+ android:layout_height="20dp"
88
+
89
+ android:gravity="right|center_vertical"
90
+
91
+ android:textSize="18sp" />
92
+
93
+
94
+
95
+ <TextView
96
+
97
+ android:id="@+id/txtAnswer"
98
+
99
+ android:layout_width="match_parent"
100
+
101
+ android:layout_height="wrap_content"
102
+
103
+ android:layout_weight="2"
104
+
105
+ android:gravity="right|center_vertical"
106
+
107
+ android:padding="16dp"
108
+
109
+ android:text="0"
110
+
111
+ android:textSize="70sp" />
112
+
113
+
114
+
115
+ <LinearLayout
116
+
117
+ android:layout_width="match_parent"
118
+
119
+ android:layout_height="wrap_content"
120
+
121
+ android:layout_weight="1"
122
+
123
+ android:orientation="horizontal">
124
+
125
+
126
+
127
+ <Button
128
+
129
+ android:id="@+id/btnSeven"
130
+
131
+ android:layout_width="wrap_content"
132
+
133
+ android:layout_height="match_parent"
134
+
135
+ android:layout_weight="1"
136
+
137
+ android:onClick="buttonIsClicked"
138
+
139
+ android:text="7"
140
+
141
+ android:textSize="46sp" />
142
+
143
+
144
+
145
+ <Button
146
+
147
+ android:id="@+id/btnEight"
148
+
149
+ android:layout_width="wrap_content"
150
+
151
+ android:layout_height="match_parent"
152
+
153
+ android:layout_weight="1"
154
+
155
+ android:onClick="buttonIsClicked"
156
+
157
+ android:text="8"
158
+
159
+ android:textSize="46sp" />
160
+
161
+
162
+
163
+ <Button
164
+
165
+ android:id="@+id/btnNine"
166
+
167
+ android:layout_width="wrap_content"
168
+
169
+ android:layout_height="match_parent"
170
+
171
+ android:layout_weight="1"
172
+
173
+ android:onClick="buttonIsClicked"
174
+
175
+ android:text="9"
176
+
177
+ android:textSize="46sp" />
178
+
179
+
180
+
181
+ <Button
182
+
183
+ android:id="@+id/btnDivision"
184
+
185
+ android:layout_width="wrap_content"
186
+
187
+ android:layout_height="match_parent"
188
+
189
+ android:layout_weight="1"
190
+
191
+ android:onClick="buttonIsClicked"
192
+
193
+ android:text="÷"
194
+
195
+ android:textSize="46sp" />
196
+
197
+ </LinearLayout>
198
+
199
+
200
+
201
+ <LinearLayout
202
+
203
+ android:layout_width="match_parent"
204
+
205
+ android:layout_height="wrap_content"
206
+
207
+ android:layout_weight="1"
208
+
209
+ android:orientation="horizontal">
210
+
211
+
212
+
213
+ <Button
214
+
215
+ android:id="@+id/btnFour"
216
+
217
+ android:layout_width="wrap_content"
218
+
219
+ android:layout_height="match_parent"
220
+
221
+ android:layout_weight="1"
222
+
223
+ android:onClick="buttonIsClicked"
224
+
225
+ android:text="4"
226
+
227
+ android:textSize="46sp" />
228
+
229
+
230
+
231
+ <Button
232
+
233
+ android:id="@+id/btnFive"
234
+
235
+ android:layout_width="wrap_content"
236
+
237
+ android:layout_height="match_parent"
238
+
239
+ android:layout_weight="1"
240
+
241
+ android:onClick="buttonIsClicked"
242
+
243
+ android:text="5"
244
+
245
+ android:textSize="46sp" />
246
+
247
+
248
+
249
+ <Button
250
+
251
+ android:id="@+id/btnSix"
252
+
253
+ android:layout_width="wrap_content"
254
+
255
+ android:layout_height="match_parent"
256
+
257
+ android:layout_weight="1"
258
+
259
+ android:onClick="buttonIsClicked"
260
+
261
+ android:text="6"
262
+
263
+ android:textSize="46sp" />
264
+
265
+
266
+
267
+ <Button
268
+
269
+ android:id="@+id/btnMultiplation"
270
+
271
+ android:layout_width="wrap_content"
272
+
273
+ android:layout_height="match_parent"
274
+
275
+ android:layout_weight="1"
276
+
277
+ android:onClick="buttonIsClicked"
278
+
279
+ android:text="×"
280
+
281
+ android:textSize="46sp" />
282
+
283
+ </LinearLayout>
284
+
285
+
286
+
287
+ <LinearLayout
288
+
289
+ android:layout_width="match_parent"
290
+
291
+ android:layout_height="wrap_content"
292
+
293
+ android:layout_weight="1"
294
+
295
+ android:orientation="horizontal">
296
+
297
+
298
+
299
+ <Button
300
+
301
+ android:id="@+id/btnOne"
302
+
303
+ android:layout_width="wrap_content"
304
+
305
+ android:layout_height="match_parent"
306
+
307
+ android:layout_weight="1"
308
+
309
+ android:onClick="buttonIsClicked"
310
+
311
+ android:text="1"
312
+
313
+ android:textSize="46sp" />
314
+
315
+
316
+
317
+ <Button
318
+
319
+ android:id="@+id/btnTwo"
320
+
321
+ android:layout_width="wrap_content"
322
+
323
+ android:layout_height="match_parent"
324
+
325
+ android:layout_weight="1"
326
+
327
+ android:onClick="buttonIsClicked"
328
+
329
+ android:text="2"
330
+
331
+ android:textSize="46sp" />
332
+
333
+
334
+
335
+ <Button
336
+
337
+ android:id="@+id/btnThree"
338
+
339
+ android:layout_width="wrap_content"
340
+
341
+ android:layout_height="match_parent"
342
+
343
+ android:layout_weight="1"
344
+
345
+ android:onClick="buttonIsClicked"
346
+
347
+ android:text="3"
348
+
349
+ android:textSize="46sp" />
350
+
351
+
352
+
353
+ <Button
354
+
355
+ android:id="@+id/btnMinus"
356
+
357
+ android:layout_width="wrap_content"
358
+
359
+ android:layout_height="match_parent"
360
+
361
+ android:layout_weight="1"
362
+
363
+ android:onClick="buttonIsClicked"
364
+
365
+ android:text="-"
366
+
367
+ android:textSize="46sp" />
368
+
369
+ </LinearLayout>
370
+
371
+
372
+
373
+ <LinearLayout
374
+
375
+ android:layout_width="match_parent"
376
+
377
+ android:layout_height="wrap_content"
378
+
379
+ android:layout_weight="1"
380
+
381
+ android:orientation="horizontal">
382
+
383
+
384
+
385
+ <Button
386
+
387
+ android:id="@+id/btnClear"
388
+
389
+ android:layout_width="wrap_content"
390
+
391
+ android:layout_height="match_parent"
392
+
393
+ android:layout_weight="1"
394
+
395
+ android:onClick="buttonIsClicked"
396
+
397
+ android:text="C"
398
+
399
+ android:textSize="46sp" />
400
+
401
+
402
+
403
+ <Button
404
+
405
+ android:id="@+id/btnZero"
406
+
407
+ android:layout_width="wrap_content"
408
+
409
+ android:layout_height="match_parent"
410
+
411
+ android:layout_weight="1"
412
+
413
+ android:onClick="buttonIsClicked"
414
+
415
+ android:text="0"
416
+
417
+ android:textSize="46sp" />
418
+
419
+
420
+
421
+ <Button
422
+
423
+ android:id="@+id/btnEqual"
424
+
425
+ android:layout_width="wrap_content"
426
+
427
+ android:layout_height="match_parent"
428
+
429
+ android:layout_weight="1"
430
+
431
+ android:onClick="buttonIsClicked"
432
+
433
+ android:text="="
434
+
435
+ android:textSize="46sp" />
436
+
437
+
438
+
439
+ <Button
440
+
441
+ android:id="@+id/btnPlus"
442
+
443
+ android:layout_width="wrap_content"
444
+
445
+ android:layout_height="match_parent"
446
+
447
+ android:layout_weight="1"
448
+
449
+ android:onClick="buttonIsClicked"
450
+
451
+ android:text="+"
452
+
453
+ android:textSize="46sp" />
454
+
455
+ </LinearLayout>
456
+
457
+
458
+
459
+
460
+
461
+ </LinearLayout>
462
+
463
+
464
+
465
+ </android.support.constraint.ConstraintLayout>
54
466
 
55
467
  ```
56
468
 
57
-
58
-
59
- AndroidManifest.xml
60
-
61
- ```
62
-
63
- <?xml version="1.0" encoding="utf-8"?>
64
-
65
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
66
-
67
- package="com.kurus.calculator">
68
-
69
-
70
-
71
- <application
72
-
73
- android:allowBackup="true"
74
-
75
- android:icon="@mipmap/ic_launcher"
76
-
77
- android:label="@string/app_name"
78
-
79
- android:roundIcon="@mipmap/ic_launcher_round"
80
-
81
- android:supportsRtl="true"
82
-
83
- android:theme="@style/AppTheme">
84
-
85
- <activity android:name=".MainActivity">
86
-
87
- <intent-filter>
88
-
89
- <action android:name="android.intent.action.MAIN" />
90
-
91
-
92
-
93
- <category android:name="android.intent.category.LAUNCHER" />
94
-
95
- </intent-filter>
96
-
97
- </activity>
98
-
99
- </application>
100
-
101
-
102
-
103
- </manifest>
104
-
105
- ```
106
-
107
- MainActivity.java
108
-
109
- ```
110
-
111
- package com.kurus.calculator;
112
-
113
-
114
-
115
- import android.os.Bundle;
116
-
117
- import android.support.v7.app.AppCompatActivity;
118
-
119
-
120
-
121
- public class MainActivity extends AppCompatActivity {
122
-
123
-
124
-
125
- @Override
126
-
127
- protected void onCreate(Bundle savedInstanceState) {
128
-
129
- super.onCreate(savedInstanceState);
130
-
131
- setContentView(R.layout.activity_main);
132
-
133
-
134
-
135
- }
136
-
137
- }
138
-
139
- ```
140
-
141
469
  ### 試したこと
142
470
 
143
471