質問編集履歴
2
activity_main.xmlのコード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,226 +11,62 @@
|
|
11
11
|

|
12
12
|

|
13
13
|
### 該当のソースコード
|
14
|
-
|
15
|
-
|
14
|
+
styles.xml
|
16
15
|
```
|
17
|
-
<?xml version="1.0" encoding="utf-8"?>
|
18
|
-
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
19
|
-
xmlns:app="http://schemas.android.com/apk/res-auto"
|
20
|
-
xmlns:tools="http://schemas.android.com/tools"
|
21
|
-
android:layout_width="match_parent"
|
22
|
-
android:layout_height="match_parent"
|
23
|
-
|
16
|
+
<resources>
|
24
17
|
|
18
|
+
<!-- Base application theme. -->
|
19
|
+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
20
|
+
<!-- Customize your theme here. -->
|
21
|
+
<item name="colorPrimary">@color/colorPrimary</item>
|
22
|
+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
23
|
+
<item name="colorAccent">@color/colorAccent</item>
|
25
|
-
<
|
24
|
+
</style>
|
26
|
-
android:layout_width="395dp"
|
27
|
-
android:layout_height="715dp"
|
28
|
-
android:layout_marginStart="8dp"
|
29
|
-
android:layout_marginLeft="8dp"
|
30
|
-
android:layout_marginTop="8dp"
|
31
|
-
android:layout_marginEnd="8dp"
|
32
|
-
android:layout_marginRight="8dp"
|
33
|
-
android:layout_marginBottom="8dp"
|
34
|
-
android:orientation="vertical"
|
35
|
-
app:layout_constraintBottom_toBottomOf="parent"
|
36
|
-
app:layout_constraintEnd_toEndOf="parent"
|
37
|
-
app:layout_constraintHorizontal_bias="0.0"
|
38
|
-
app:layout_constraintStart_toStartOf="parent"
|
39
|
-
app:layout_constraintTop_toTopOf="parent">
|
40
25
|
|
41
|
-
<TextView
|
42
|
-
|
26
|
+
</resources>
|
43
|
-
android:layout_width="match_parent"
|
44
|
-
android:layout_height="20dp"
|
45
|
-
android:gravity="right|center_vertical"
|
46
|
-
android:textSize="18sp" />
|
47
27
|
|
48
|
-
|
28
|
+
```
|
49
|
-
android:id="@+id/txtAnswer"
|
50
|
-
android:layout_width="match_parent"
|
51
|
-
android:layout_height="wrap_content"
|
52
|
-
android:layout_weight="2"
|
53
|
-
android:gravity="right|center_vertical"
|
54
|
-
android:padding="16dp"
|
55
|
-
android:text="0"
|
56
|
-
android:textSize="70sp" />
|
57
29
|
|
58
|
-
<LinearLayout
|
59
|
-
android:layout_width="match_parent"
|
60
|
-
android:layout_height="wrap_content"
|
61
|
-
|
30
|
+
AndroidManifest.xml
|
31
|
+
```
|
62
|
-
|
32
|
+
<?xml version="1.0" encoding="utf-8"?>
|
33
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
34
|
+
package="com.kurus.calculator">
|
63
35
|
|
64
|
-
|
36
|
+
<application
|
37
|
+
android:allowBackup="true"
|
65
|
-
|
38
|
+
android:icon="@mipmap/ic_launcher"
|
66
|
-
android:layout_width="wrap_content"
|
67
|
-
android:layout_height="match_parent"
|
68
|
-
android:layout_weight="1"
|
69
|
-
|
39
|
+
android:label="@string/app_name"
|
40
|
+
android:roundIcon="@mipmap/ic_launcher_round"
|
70
|
-
|
41
|
+
android:supportsRtl="true"
|
71
|
-
|
42
|
+
android:theme="@style/AppTheme">
|
43
|
+
<activity android:name=".MainActivity">
|
44
|
+
<intent-filter>
|
45
|
+
<action android:name="android.intent.action.MAIN" />
|
72
46
|
|
73
|
-
<Button
|
74
|
-
android:id="@+id/btnEight"
|
75
|
-
android:layout_width="wrap_content"
|
76
|
-
android:layout_height="match_parent"
|
77
|
-
android:layout_weight="1"
|
78
|
-
android:onClick="buttonIsClicked"
|
79
|
-
android:text="8"
|
80
|
-
android:
|
47
|
+
<category android:name="android.intent.category.LAUNCHER" />
|
48
|
+
</intent-filter>
|
49
|
+
</activity>
|
50
|
+
</application>
|
81
51
|
|
82
|
-
<Button
|
83
|
-
|
52
|
+
</manifest>
|
84
|
-
|
53
|
+
```
|
85
|
-
android:layout_height="match_parent"
|
86
|
-
|
54
|
+
MainActivity.java
|
87
|
-
|
55
|
+
```
|
88
|
-
|
56
|
+
package com.kurus.calculator;
|
89
|
-
android:textSize="46sp" />
|
90
57
|
|
91
|
-
<Button
|
92
|
-
android:id="@+id/btnDivision"
|
93
|
-
|
58
|
+
import android.os.Bundle;
|
94
|
-
android:layout_height="match_parent"
|
95
|
-
|
59
|
+
import android.support.v7.app.AppCompatActivity;
|
96
|
-
android:onClick="buttonIsClicked"
|
97
|
-
android:text="÷"
|
98
|
-
android:textSize="46sp" />
|
99
|
-
</LinearLayout>
|
100
60
|
|
101
|
-
<LinearLayout
|
102
|
-
android:layout_width="match_parent"
|
103
|
-
|
61
|
+
public class MainActivity extends AppCompatActivity {
|
104
|
-
android:layout_weight="1"
|
105
|
-
android:orientation="horizontal">
|
106
62
|
|
107
|
-
|
63
|
+
@Override
|
108
|
-
android:id="@+id/btnFour"
|
109
|
-
android:layout_width="wrap_content"
|
110
|
-
android:layout_height="match_parent"
|
111
|
-
android:layout_weight="1"
|
112
|
-
|
64
|
+
protected void onCreate(Bundle savedInstanceState) {
|
113
|
-
|
65
|
+
super.onCreate(savedInstanceState);
|
114
|
-
|
66
|
+
setContentView(R.layout.activity_main);
|
115
67
|
|
116
|
-
|
68
|
+
}
|
117
|
-
android:id="@+id/btnFive"
|
118
|
-
android:layout_width="wrap_content"
|
119
|
-
android:layout_height="match_parent"
|
120
|
-
android:layout_weight="1"
|
121
|
-
android:onClick="buttonIsClicked"
|
122
|
-
android:text="5"
|
123
|
-
android:textSize="46sp" />
|
124
|
-
|
125
|
-
|
69
|
+
}
|
126
|
-
android:id="@+id/btnSix"
|
127
|
-
android:layout_width="wrap_content"
|
128
|
-
android:layout_height="match_parent"
|
129
|
-
android:layout_weight="1"
|
130
|
-
android:onClick="buttonIsClicked"
|
131
|
-
android:text="6"
|
132
|
-
android:textSize="46sp" />
|
133
|
-
|
134
|
-
<Button
|
135
|
-
android:id="@+id/btnMultiplation"
|
136
|
-
android:layout_width="wrap_content"
|
137
|
-
android:layout_height="match_parent"
|
138
|
-
android:layout_weight="1"
|
139
|
-
android:onClick="buttonIsClicked"
|
140
|
-
android:text="×"
|
141
|
-
android:textSize="46sp" />
|
142
|
-
</LinearLayout>
|
143
|
-
|
144
|
-
<LinearLayout
|
145
|
-
android:layout_width="match_parent"
|
146
|
-
android:layout_height="wrap_content"
|
147
|
-
android:layout_weight="1"
|
148
|
-
android:orientation="horizontal">
|
149
|
-
|
150
|
-
<Button
|
151
|
-
android:id="@+id/btnOne"
|
152
|
-
android:layout_width="wrap_content"
|
153
|
-
android:layout_height="match_parent"
|
154
|
-
android:layout_weight="1"
|
155
|
-
android:onClick="buttonIsClicked"
|
156
|
-
android:text="1"
|
157
|
-
android:textSize="46sp" />
|
158
|
-
|
159
|
-
<Button
|
160
|
-
android:id="@+id/btnTwo"
|
161
|
-
android:layout_width="wrap_content"
|
162
|
-
android:layout_height="match_parent"
|
163
|
-
android:layout_weight="1"
|
164
|
-
android:onClick="buttonIsClicked"
|
165
|
-
android:text="2"
|
166
|
-
android:textSize="46sp" />
|
167
|
-
|
168
|
-
<Button
|
169
|
-
android:id="@+id/btnThree"
|
170
|
-
android:layout_width="wrap_content"
|
171
|
-
android:layout_height="match_parent"
|
172
|
-
android:layout_weight="1"
|
173
|
-
android:onClick="buttonIsClicked"
|
174
|
-
android:text="3"
|
175
|
-
android:textSize="46sp" />
|
176
|
-
|
177
|
-
<Button
|
178
|
-
android:id="@+id/btnMinus"
|
179
|
-
android:layout_width="wrap_content"
|
180
|
-
android:layout_height="match_parent"
|
181
|
-
android:layout_weight="1"
|
182
|
-
android:onClick="buttonIsClicked"
|
183
|
-
android:text="-"
|
184
|
-
android:textSize="46sp" />
|
185
|
-
</LinearLayout>
|
186
|
-
|
187
|
-
<LinearLayout
|
188
|
-
android:layout_width="match_parent"
|
189
|
-
android:layout_height="wrap_content"
|
190
|
-
android:layout_weight="1"
|
191
|
-
android:orientation="horizontal">
|
192
|
-
|
193
|
-
<Button
|
194
|
-
android:id="@+id/btnClear"
|
195
|
-
android:layout_width="wrap_content"
|
196
|
-
android:layout_height="match_parent"
|
197
|
-
android:layout_weight="1"
|
198
|
-
android:onClick="buttonIsClicked"
|
199
|
-
android:text="C"
|
200
|
-
android:textSize="46sp" />
|
201
|
-
|
202
|
-
<Button
|
203
|
-
android:id="@+id/btnZero"
|
204
|
-
android:layout_width="wrap_content"
|
205
|
-
android:layout_height="match_parent"
|
206
|
-
android:layout_weight="1"
|
207
|
-
android:onClick="buttonIsClicked"
|
208
|
-
android:text="0"
|
209
|
-
android:textSize="46sp" />
|
210
|
-
|
211
|
-
<Button
|
212
|
-
android:id="@+id/btnEqual"
|
213
|
-
android:layout_width="wrap_content"
|
214
|
-
android:layout_height="match_parent"
|
215
|
-
android:layout_weight="1"
|
216
|
-
android:onClick="buttonIsClicked"
|
217
|
-
android:text="="
|
218
|
-
android:textSize="46sp" />
|
219
|
-
|
220
|
-
<Button
|
221
|
-
android:id="@+id/btnPlus"
|
222
|
-
android:layout_width="wrap_content"
|
223
|
-
android:layout_height="match_parent"
|
224
|
-
android:layout_weight="1"
|
225
|
-
android:onClick="buttonIsClicked"
|
226
|
-
android:text="+"
|
227
|
-
android:textSize="46sp" />
|
228
|
-
</LinearLayout>
|
229
|
-
|
230
|
-
|
231
|
-
</LinearLayout>
|
232
|
-
|
233
|
-
</android.support.constraint.ConstraintLayout>
|
234
70
|
```
|
235
71
|
### 試したこと
|
236
72
|
|
1
activity_main.xmlのコード追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,62 +11,226 @@
|
|
11
11
|

|
12
12
|

|
13
13
|
### 該当のソースコード
|
14
|
+
|
14
|
-
|
15
|
+
activity_main.xml
|
15
16
|
```
|
17
|
+
<?xml version="1.0" encoding="utf-8"?>
|
18
|
+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
19
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
20
|
+
xmlns:tools="http://schemas.android.com/tools"
|
21
|
+
android:layout_width="match_parent"
|
22
|
+
android:layout_height="match_parent"
|
16
|
-
|
23
|
+
tools:context=".MainActivity">
|
17
24
|
|
18
|
-
<!-- Base application theme. -->
|
19
|
-
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
20
|
-
<!-- Customize your theme here. -->
|
21
|
-
<item name="colorPrimary">@color/colorPrimary</item>
|
22
|
-
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
23
|
-
<item name="colorAccent">@color/colorAccent</item>
|
24
|
-
<
|
25
|
+
<LinearLayout
|
26
|
+
android:layout_width="395dp"
|
27
|
+
android:layout_height="715dp"
|
28
|
+
android:layout_marginStart="8dp"
|
29
|
+
android:layout_marginLeft="8dp"
|
30
|
+
android:layout_marginTop="8dp"
|
31
|
+
android:layout_marginEnd="8dp"
|
32
|
+
android:layout_marginRight="8dp"
|
33
|
+
android:layout_marginBottom="8dp"
|
34
|
+
android:orientation="vertical"
|
35
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
36
|
+
app:layout_constraintEnd_toEndOf="parent"
|
37
|
+
app:layout_constraintHorizontal_bias="0.0"
|
38
|
+
app:layout_constraintStart_toStartOf="parent"
|
39
|
+
app:layout_constraintTop_toTopOf="parent">
|
25
40
|
|
41
|
+
<TextView
|
26
|
-
|
42
|
+
android:id="@+id/txtStatus"
|
43
|
+
android:layout_width="match_parent"
|
44
|
+
android:layout_height="20dp"
|
45
|
+
android:gravity="right|center_vertical"
|
46
|
+
android:textSize="18sp" />
|
27
47
|
|
28
|
-
|
48
|
+
<TextView
|
49
|
+
android:id="@+id/txtAnswer"
|
50
|
+
android:layout_width="match_parent"
|
51
|
+
android:layout_height="wrap_content"
|
52
|
+
android:layout_weight="2"
|
53
|
+
android:gravity="right|center_vertical"
|
54
|
+
android:padding="16dp"
|
55
|
+
android:text="0"
|
56
|
+
android:textSize="70sp" />
|
29
57
|
|
58
|
+
<LinearLayout
|
59
|
+
android:layout_width="match_parent"
|
60
|
+
android:layout_height="wrap_content"
|
30
|
-
|
61
|
+
android:layout_weight="1"
|
31
|
-
```
|
32
|
-
|
62
|
+
android:orientation="horizontal">
|
33
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
34
|
-
package="com.kurus.calculator">
|
35
63
|
|
36
|
-
|
64
|
+
<Button
|
37
|
-
android:allowBackup="true"
|
38
|
-
|
65
|
+
android:id="@+id/btnSeven"
|
66
|
+
android:layout_width="wrap_content"
|
67
|
+
android:layout_height="match_parent"
|
68
|
+
android:layout_weight="1"
|
39
|
-
|
69
|
+
android:onClick="buttonIsClicked"
|
40
|
-
android:roundIcon="@mipmap/ic_launcher_round"
|
41
|
-
|
70
|
+
android:text="7"
|
42
|
-
|
71
|
+
android:textSize="46sp" />
|
43
|
-
<activity android:name=".MainActivity">
|
44
|
-
<intent-filter>
|
45
|
-
<action android:name="android.intent.action.MAIN" />
|
46
72
|
|
73
|
+
<Button
|
74
|
+
android:id="@+id/btnEight"
|
75
|
+
android:layout_width="wrap_content"
|
76
|
+
android:layout_height="match_parent"
|
77
|
+
android:layout_weight="1"
|
78
|
+
android:onClick="buttonIsClicked"
|
79
|
+
android:text="8"
|
47
|
-
|
80
|
+
android:textSize="46sp" />
|
48
|
-
</intent-filter>
|
49
|
-
</activity>
|
50
|
-
</application>
|
51
81
|
|
82
|
+
<Button
|
52
|
-
|
83
|
+
android:id="@+id/btnNine"
|
53
|
-
|
84
|
+
android:layout_width="wrap_content"
|
85
|
+
android:layout_height="match_parent"
|
54
|
-
|
86
|
+
android:layout_weight="1"
|
55
|
-
|
87
|
+
android:onClick="buttonIsClicked"
|
56
|
-
|
88
|
+
android:text="9"
|
89
|
+
android:textSize="46sp" />
|
57
90
|
|
91
|
+
<Button
|
92
|
+
android:id="@+id/btnDivision"
|
58
|
-
|
93
|
+
android:layout_width="wrap_content"
|
94
|
+
android:layout_height="match_parent"
|
59
|
-
|
95
|
+
android:layout_weight="1"
|
96
|
+
android:onClick="buttonIsClicked"
|
97
|
+
android:text="÷"
|
98
|
+
android:textSize="46sp" />
|
99
|
+
</LinearLayout>
|
60
100
|
|
101
|
+
<LinearLayout
|
102
|
+
android:layout_width="match_parent"
|
61
|
-
|
103
|
+
android:layout_height="wrap_content"
|
104
|
+
android:layout_weight="1"
|
105
|
+
android:orientation="horizontal">
|
62
106
|
|
63
|
-
|
107
|
+
<Button
|
108
|
+
android:id="@+id/btnFour"
|
109
|
+
android:layout_width="wrap_content"
|
110
|
+
android:layout_height="match_parent"
|
111
|
+
android:layout_weight="1"
|
64
|
-
|
112
|
+
android:onClick="buttonIsClicked"
|
65
|
-
|
113
|
+
android:text="4"
|
66
|
-
|
114
|
+
android:textSize="46sp" />
|
67
115
|
|
68
|
-
|
116
|
+
<Button
|
117
|
+
android:id="@+id/btnFive"
|
118
|
+
android:layout_width="wrap_content"
|
119
|
+
android:layout_height="match_parent"
|
120
|
+
android:layout_weight="1"
|
121
|
+
android:onClick="buttonIsClicked"
|
122
|
+
android:text="5"
|
123
|
+
android:textSize="46sp" />
|
124
|
+
|
69
|
-
|
125
|
+
<Button
|
126
|
+
android:id="@+id/btnSix"
|
127
|
+
android:layout_width="wrap_content"
|
128
|
+
android:layout_height="match_parent"
|
129
|
+
android:layout_weight="1"
|
130
|
+
android:onClick="buttonIsClicked"
|
131
|
+
android:text="6"
|
132
|
+
android:textSize="46sp" />
|
133
|
+
|
134
|
+
<Button
|
135
|
+
android:id="@+id/btnMultiplation"
|
136
|
+
android:layout_width="wrap_content"
|
137
|
+
android:layout_height="match_parent"
|
138
|
+
android:layout_weight="1"
|
139
|
+
android:onClick="buttonIsClicked"
|
140
|
+
android:text="×"
|
141
|
+
android:textSize="46sp" />
|
142
|
+
</LinearLayout>
|
143
|
+
|
144
|
+
<LinearLayout
|
145
|
+
android:layout_width="match_parent"
|
146
|
+
android:layout_height="wrap_content"
|
147
|
+
android:layout_weight="1"
|
148
|
+
android:orientation="horizontal">
|
149
|
+
|
150
|
+
<Button
|
151
|
+
android:id="@+id/btnOne"
|
152
|
+
android:layout_width="wrap_content"
|
153
|
+
android:layout_height="match_parent"
|
154
|
+
android:layout_weight="1"
|
155
|
+
android:onClick="buttonIsClicked"
|
156
|
+
android:text="1"
|
157
|
+
android:textSize="46sp" />
|
158
|
+
|
159
|
+
<Button
|
160
|
+
android:id="@+id/btnTwo"
|
161
|
+
android:layout_width="wrap_content"
|
162
|
+
android:layout_height="match_parent"
|
163
|
+
android:layout_weight="1"
|
164
|
+
android:onClick="buttonIsClicked"
|
165
|
+
android:text="2"
|
166
|
+
android:textSize="46sp" />
|
167
|
+
|
168
|
+
<Button
|
169
|
+
android:id="@+id/btnThree"
|
170
|
+
android:layout_width="wrap_content"
|
171
|
+
android:layout_height="match_parent"
|
172
|
+
android:layout_weight="1"
|
173
|
+
android:onClick="buttonIsClicked"
|
174
|
+
android:text="3"
|
175
|
+
android:textSize="46sp" />
|
176
|
+
|
177
|
+
<Button
|
178
|
+
android:id="@+id/btnMinus"
|
179
|
+
android:layout_width="wrap_content"
|
180
|
+
android:layout_height="match_parent"
|
181
|
+
android:layout_weight="1"
|
182
|
+
android:onClick="buttonIsClicked"
|
183
|
+
android:text="-"
|
184
|
+
android:textSize="46sp" />
|
185
|
+
</LinearLayout>
|
186
|
+
|
187
|
+
<LinearLayout
|
188
|
+
android:layout_width="match_parent"
|
189
|
+
android:layout_height="wrap_content"
|
190
|
+
android:layout_weight="1"
|
191
|
+
android:orientation="horizontal">
|
192
|
+
|
193
|
+
<Button
|
194
|
+
android:id="@+id/btnClear"
|
195
|
+
android:layout_width="wrap_content"
|
196
|
+
android:layout_height="match_parent"
|
197
|
+
android:layout_weight="1"
|
198
|
+
android:onClick="buttonIsClicked"
|
199
|
+
android:text="C"
|
200
|
+
android:textSize="46sp" />
|
201
|
+
|
202
|
+
<Button
|
203
|
+
android:id="@+id/btnZero"
|
204
|
+
android:layout_width="wrap_content"
|
205
|
+
android:layout_height="match_parent"
|
206
|
+
android:layout_weight="1"
|
207
|
+
android:onClick="buttonIsClicked"
|
208
|
+
android:text="0"
|
209
|
+
android:textSize="46sp" />
|
210
|
+
|
211
|
+
<Button
|
212
|
+
android:id="@+id/btnEqual"
|
213
|
+
android:layout_width="wrap_content"
|
214
|
+
android:layout_height="match_parent"
|
215
|
+
android:layout_weight="1"
|
216
|
+
android:onClick="buttonIsClicked"
|
217
|
+
android:text="="
|
218
|
+
android:textSize="46sp" />
|
219
|
+
|
220
|
+
<Button
|
221
|
+
android:id="@+id/btnPlus"
|
222
|
+
android:layout_width="wrap_content"
|
223
|
+
android:layout_height="match_parent"
|
224
|
+
android:layout_weight="1"
|
225
|
+
android:onClick="buttonIsClicked"
|
226
|
+
android:text="+"
|
227
|
+
android:textSize="46sp" />
|
228
|
+
</LinearLayout>
|
229
|
+
|
230
|
+
|
231
|
+
</LinearLayout>
|
232
|
+
|
233
|
+
</android.support.constraint.ConstraintLayout>
|
70
234
|
```
|
71
235
|
### 試したこと
|
72
236
|
|