質問編集履歴
1
レイアウトです!
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,284 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
import android.os.Bundle;
|
36
|
-
|
37
|
-
import android.content.Intent;
|
38
|
-
|
39
|
-
import android.view.View;
|
40
|
-
|
41
|
-
import android.widget.Button;
|
42
|
-
|
43
|
-
import android.widget.EditText;
|
44
|
-
|
45
|
-
import android.widget.LinearLayout;
|
46
|
-
|
47
|
-
import android.widget.TextView;
|
48
|
-
|
49
|
-
import android.view.View.OnClickListener;
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
public class MainActivity extends AppCompatActivity {
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
@Override
|
58
|
-
|
59
|
-
protected void onCreate(Bundle savedInstanceState) {
|
60
|
-
|
61
|
-
super.onCreate(savedInstanceState);
|
62
|
-
|
63
|
-
setContentView(R.layout.activity_main);
|
64
|
-
|
65
|
-
}
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
public void btn2_onClick(View view){
|
72
|
-
|
73
|
-
Intent intent=new Intent(this,to.msn.wings.ourapp.SubActivity2.class);
|
74
|
-
|
75
|
-
//アクティビティを起動(サブ画面起動)
|
76
|
-
|
77
|
-
startActivityForResult(intent,0);
|
78
|
-
|
79
|
-
}
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
@Override
|
84
|
-
|
85
|
-
protected void onActivityResult(int requestCode,int resultCode,Intent data){
|
86
|
-
|
87
|
-
super.onActivityResult(requestCode, resultCode, data);
|
88
|
-
|
89
|
-
//リクエストコードと結果コードをチェック
|
90
|
-
|
91
|
-
if(requestCode==0 && resultCode==RESULT_OK){
|
92
|
-
|
93
|
-
//結果のコードを取得&ボタンのテクストに記入
|
94
|
-
|
95
|
-
String txtName=data.getStringExtra("txtName");
|
96
|
-
|
97
|
-
String numPicker=data.getStringExtra("numPicker");
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
}
|
102
|
-
|
103
|
-
}
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
=======Sub_Activity2.java========
|
112
|
-
|
113
|
-
package to.msn.wings.ourapp;
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
import android.content.Intent;
|
118
|
-
|
119
|
-
import android.os.Bundle;
|
120
|
-
|
121
|
-
import androidx.appcompat.app.AppCompatActivity;
|
122
|
-
|
123
|
-
import android.view.View;
|
124
|
-
|
125
|
-
import android.view.View.OnClickListener;
|
126
|
-
|
127
|
-
import android.widget.Button;
|
128
|
-
|
129
|
-
import android.widget.EditText;
|
130
|
-
|
131
|
-
import android.widget.NumberPicker;
|
132
|
-
|
133
|
-
import android.widget.TextView;
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
public class SubActivity2 extends AppCompatActivity{
|
140
|
-
|
141
|
-
private NumberPicker numPicker0;
|
142
|
-
|
143
|
-
private TextView pickerTextView;
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
private String[] figures=new String[1];
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
@Override
|
152
|
-
|
153
|
-
protected void onCreate(Bundle savedInstanceState){
|
154
|
-
|
155
|
-
super.onCreate(savedInstanceState);
|
156
|
-
|
157
|
-
setContentView(R.layout.activity_sub2);
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
pickerTextView=findViewById(R.id.text_view);
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
Button pickerButton=findViewById(R.id.button88);
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
//ドラムロールに表示したい値を含んだ配列を作る
|
172
|
-
|
173
|
-
final String[] pref={"月1","月2","月3","月4","月5","月6","火1",
|
174
|
-
|
175
|
-
"火2","火3","火4","火5","火6","水1","水2","水3","水4",
|
176
|
-
|
177
|
-
"水5","水6","木1","木2","木3","木4","木5","木6","金1",
|
178
|
-
|
179
|
-
"金2","金3","金4","金5","金6","土1","土2","土3","土4","土5","土6"};
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
//numberPickerをインスタンス化する
|
186
|
-
|
187
|
-
final NumberPicker picker=findViewById(R.id.numPicker0);
|
188
|
-
|
189
|
-
//配列のインデックスの最小、最大を指定する
|
190
|
-
|
191
|
-
picker.setMinValue(0);
|
192
|
-
|
193
|
-
picker.setMaxValue(36);
|
194
|
-
|
195
|
-
//numberpickerに配列をセットする
|
196
|
-
|
197
|
-
picker.setDisplayedValues(pref);
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
pickerButton.setOnClickListener(new OnClickListener() {
|
202
|
-
|
203
|
-
public void onClick(View v){
|
204
|
-
|
205
|
-
figures[0]=String.valueOf(numPicker0.getValue());
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
String str=String.format("%s",
|
210
|
-
|
211
|
-
figures[0]);
|
212
|
-
|
213
|
-
Float fig=Float.parseFloat(str);
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
pickerTextView.setText(String.valueOf(fig));
|
218
|
-
|
219
|
-
}
|
220
|
-
|
221
|
-
});
|
222
|
-
|
223
|
-
}
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
//ボタンクリック時に呼び出されるメソッド
|
228
|
-
|
229
|
-
public void btn88_onClick(View v){
|
230
|
-
|
231
|
-
//インテントを生成&データをセット
|
232
|
-
|
233
|
-
//講義名のインテント
|
234
|
-
|
235
|
-
Intent i=new Intent(this,to.msn.wings.ourapp.MainActivity.class);
|
236
|
-
|
237
|
-
EditText txtName=findViewById(R.id.txtName);
|
238
|
-
|
239
|
-
i.putExtra("txtName",txtName.getText().toString());
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
//教室のインテント
|
244
|
-
|
245
|
-
EditText txtName2=findViewById(R.id.txtName2);
|
246
|
-
|
247
|
-
i.putExtra("txtName2",txtName.getText().toString());
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
//numberPickerのインテント
|
252
|
-
|
253
|
-
NumberPicker numPicker0=findViewById(R.id.numPicker0);
|
254
|
-
|
255
|
-
i.putExtra("numPicker",txtName.getText().toString());
|
256
|
-
|
257
|
-
//結果情報をセット
|
258
|
-
|
259
|
-
setResult(RESULT_OK,i);
|
260
|
-
|
261
|
-
//現在のアクティビティを終了
|
262
|
-
|
263
|
-
finish();
|
264
|
-
|
265
|
-
}
|
266
|
-
|
267
|
-
}
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
###試したこと
|
278
|
-
|
279
|
-
1つ目の課題に関しては該当のbuttonに
|
280
|
-
|
281
|
-
<Button
|
1
|
+
```
|
2
|
+
|
3
|
+
```java(activity_main)
|
4
|
+
|
5
|
+
<?xml version="1.0" encoding="utf-8"?>
|
6
|
+
|
7
|
+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
8
|
+
|
9
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
10
|
+
|
11
|
+
xmlns:tools="http://schemas.android.com/tools"
|
12
|
+
|
13
|
+
android:layout_width="match_parent"
|
14
|
+
|
15
|
+
android:layout_height="match_parent"
|
16
|
+
|
17
|
+
android:orientation="vertical">
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
<androidx.constraintlayout.widget.ConstraintLayout
|
24
|
+
|
25
|
+
android:layout_width="match_parent"
|
26
|
+
|
27
|
+
android:layout_height="wrap_content">
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
<Button
|
282
32
|
|
283
33
|
android:id="@+id/btn2"
|
284
34
|
|
@@ -300,14 +50,348 @@
|
|
300
50
|
|
301
51
|
android:onClick="btn2_onClick"/>
|
302
52
|
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
53
|
+
|
54
|
+
|
55
|
+
<Button
|
56
|
+
|
57
|
+
android:id="@+id/btn1"
|
58
|
+
|
59
|
+
android:layout_width="wrap_content"
|
60
|
+
|
61
|
+
android:layout_height="wrap_content"
|
62
|
+
|
63
|
+
android:layout_gravity="top"
|
64
|
+
|
65
|
+
android:layout_marginStart="8dp"
|
66
|
+
|
67
|
+
android:layout_marginTop="8dp"
|
68
|
+
|
69
|
+
android:text="写真選択"
|
70
|
+
|
71
|
+
app:layout_constraintStart_toStartOf="parent"
|
72
|
+
|
73
|
+
app:layout_constraintTop_toTopOf="parent" />
|
74
|
+
|
75
|
+
</androidx.constraintlayout.widget.ConstraintLayout>
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
<LinearLayout
|
84
|
+
|
85
|
+
android:layout_width="match_parent"
|
86
|
+
|
87
|
+
android:layout_height="50dp"
|
88
|
+
|
89
|
+
android:orientation="vertical">
|
90
|
+
|
91
|
+
</LinearLayout>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<TableLayout
|
96
|
+
|
97
|
+
android:layout_width="match_parent"
|
98
|
+
|
99
|
+
android:layout_height="match_parent"
|
100
|
+
|
101
|
+
android:orientation="vertical"
|
102
|
+
|
103
|
+
android:shrinkColumns="0,1,2,3,4,5,6">
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
<TableRow
|
108
|
+
|
109
|
+
android:layout_width="match_parent"
|
110
|
+
|
111
|
+
android:layout_height="match_parent">
|
112
|
+
|
113
|
+
<Button
|
114
|
+
|
115
|
+
android:layout_width="wrap_content"
|
116
|
+
|
117
|
+
android:layout_height="wrap_content"/>
|
118
|
+
|
119
|
+
<Button
|
120
|
+
|
121
|
+
android:layout_width="wrap_content"
|
122
|
+
|
123
|
+
android:layout_height="wrap_content"
|
124
|
+
|
125
|
+
android:text="月"/>
|
126
|
+
|
127
|
+
<Button
|
128
|
+
|
129
|
+
android:layout_width="wrap_content"
|
130
|
+
|
131
|
+
android:layout_height="wrap_content"
|
132
|
+
|
133
|
+
android:text="火"/>
|
134
|
+
|
135
|
+
<Button
|
136
|
+
|
137
|
+
android:layout_width="wrap_content"
|
138
|
+
|
139
|
+
android:layout_height="wrap_content"
|
140
|
+
|
141
|
+
android:text="水"/>
|
142
|
+
|
143
|
+
<Button
|
144
|
+
|
145
|
+
android:layout_width="wrap_content"
|
146
|
+
|
147
|
+
android:layout_height="wrap_content"
|
148
|
+
|
149
|
+
android:text="木"/>
|
150
|
+
|
151
|
+
<Button
|
152
|
+
|
153
|
+
android:layout_width="wrap_content"
|
154
|
+
|
155
|
+
android:layout_height="wrap_content"
|
156
|
+
|
157
|
+
android:text="金"/>
|
158
|
+
|
159
|
+
<Button
|
160
|
+
|
161
|
+
android:layout_width="wrap_content"
|
162
|
+
|
163
|
+
android:layout_height="wrap_content"
|
164
|
+
|
165
|
+
android:text="土"/>
|
166
|
+
|
167
|
+
</TableRow>
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
<TableRow
|
172
|
+
|
173
|
+
android:layout_width="match_parent"
|
174
|
+
|
175
|
+
android:layout_height="match_parent">
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
<Button
|
180
|
+
|
181
|
+
android:layout_width="wrap_content"
|
182
|
+
|
183
|
+
android:layout_height="wrap_content"
|
184
|
+
|
185
|
+
android:text="1" />
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
<Button
|
190
|
+
|
191
|
+
android:id="@+id/btn46"
|
192
|
+
|
193
|
+
android:layout_width="wrap_content"
|
194
|
+
|
195
|
+
android:layout_height="wrap_content"
|
196
|
+
|
197
|
+
android:onClick="btn46_onClick />
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
<Button
|
202
|
+
|
203
|
+
android:id="@+id/btn47"
|
204
|
+
|
205
|
+
android:layout_width="wrap_content"
|
206
|
+
|
207
|
+
android:layout_height="wrap_content"
|
208
|
+
|
209
|
+
android:onClick="btn47_onClick" />
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
<Button
|
214
|
+
|
215
|
+
android:id="@+id/btn48"
|
216
|
+
|
217
|
+
android:layout_width="wrap_content"
|
218
|
+
|
219
|
+
android:layout_height="wrap_content"
|
220
|
+
|
221
|
+
android:onClick="btn48_onClick" />
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
<Button
|
226
|
+
|
227
|
+
android:id="@+id/btn49"
|
228
|
+
|
229
|
+
android:layout_width="wrap_content"
|
230
|
+
|
231
|
+
android:layout_height="wrap_content"
|
232
|
+
|
233
|
+
android:onClick="btn49_onClick" />
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
<Button
|
238
|
+
|
239
|
+
android:id="@+id/btn50"
|
240
|
+
|
241
|
+
android:layout_width="wrap_content"
|
242
|
+
|
243
|
+
android:layout_height="wrap_content"
|
244
|
+
|
245
|
+
android:onClick="btn50_onClick" />
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
<Button
|
250
|
+
|
251
|
+
android:id="@+id/btn51"
|
252
|
+
|
253
|
+
android:layout_width="wrap_content"
|
254
|
+
|
255
|
+
android:layout_height="wrap_content"
|
256
|
+
|
257
|
+
android:onClick="btn51_onClick" />
|
258
|
+
|
259
|
+
</TableRow>
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
<TableRow
|
264
|
+
|
265
|
+
android:layout_width="match_parent"
|
266
|
+
|
267
|
+
android:layout_height="match_parent">
|
268
|
+
|
269
|
+
<Button
|
270
|
+
|
271
|
+
android:layout_width="wrap_content"
|
272
|
+
|
273
|
+
android:layout_height="wrap_content"
|
274
|
+
|
275
|
+
android:text="2"/>.....android:text1と同様に6まで続きます。
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
```
|
280
|
+
|
281
|
+
```java(activity_sub2)
|
282
|
+
|
283
|
+
<?xml version="1.0" encoding="utf-8"?>
|
284
|
+
|
285
|
+
<LinearLayout
|
286
|
+
|
287
|
+
xmlns:android="http://schemas.android.com/apk/res/android"
|
288
|
+
|
289
|
+
android:layout_width="match_parent"
|
290
|
+
|
291
|
+
android:layout_height="match_parent"
|
292
|
+
|
293
|
+
android:orientation="vertical">
|
294
|
+
|
295
|
+
|
296
|
+
|
297
|
+
<EditText
|
298
|
+
|
299
|
+
android:id="@+id/txtName"
|
300
|
+
|
301
|
+
android:layout_width="match_parent"
|
302
|
+
|
303
|
+
android:layout_height="wrap_content"
|
304
|
+
|
305
|
+
android:inputType="text"
|
306
|
+
|
307
|
+
android:hint="講義名を入力してください。">
|
308
|
+
|
309
|
+
</EditText>
|
310
|
+
|
311
|
+
<EditText
|
312
|
+
|
313
|
+
android:id="@+id/txtName2"
|
314
|
+
|
315
|
+
android:layout_width="match_parent"
|
316
|
+
|
317
|
+
android:layout_height="wrap_content"
|
318
|
+
|
319
|
+
android:inputType="text"
|
320
|
+
|
321
|
+
android:hint="教室を入力してください。">
|
322
|
+
|
323
|
+
</EditText>
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
<TextView
|
330
|
+
|
331
|
+
android:id="@+id/text_view"
|
332
|
+
|
333
|
+
android:layout_width="wrap_content"
|
334
|
+
|
335
|
+
android:layout_height="wrap_content"
|
336
|
+
|
337
|
+
android:layout_gravity="center"
|
338
|
+
|
339
|
+
android:layout_margin="30dp"
|
340
|
+
|
341
|
+
android:textStyle="bold"
|
342
|
+
|
343
|
+
android:text="@string/時間割"
|
344
|
+
|
345
|
+
android:textColor="#00f"
|
346
|
+
|
347
|
+
android:textSize="40sp"/>
|
348
|
+
|
349
|
+
<LinearLayout
|
350
|
+
|
351
|
+
android:layout_width="match_parent"
|
352
|
+
|
353
|
+
android:layout_height="wrap_content"
|
354
|
+
|
355
|
+
android:gravity="center"
|
356
|
+
|
357
|
+
android:layout_margin="10dp"
|
358
|
+
|
359
|
+
android:orientation="horizontal">
|
360
|
+
|
361
|
+
<NumberPicker
|
362
|
+
|
363
|
+
android:id="@+id/numPicker0"
|
364
|
+
|
365
|
+
android:layout_width="wrap_content"
|
366
|
+
|
367
|
+
android:layout_height="wrap_content"
|
368
|
+
|
369
|
+
android:background="#aaf"/>/>
|
370
|
+
|
371
|
+
</LinearLayout>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
<Button
|
376
|
+
|
377
|
+
android:id="@+id/button88"
|
378
|
+
|
379
|
+
android:layout_width="match_parent"
|
380
|
+
|
381
|
+
android:layout_height="wrap_content"
|
382
|
+
|
383
|
+
android:layout_margin="40dp"
|
384
|
+
|
385
|
+
android:text="@string/ok"
|
386
|
+
|
387
|
+
android:onClick="btn88_onClick"/>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
</LinearLayout>
|
396
|
+
|
397
|
+
```
|