質問編集履歴
2
コードを打ち込みました
title
CHANGED
File without changes
|
body
CHANGED
@@ -2,7 +2,51 @@
|
|
2
2
|
if文のプログラムを動かしたいのですが,調べても分からなかったので質問します。
|
3
3
|
条件式は書けているですが,動きません。初歩的なことで申し訳ないのですが,教えてください。
|
4
4
|
|
5
|
-
状況は下の画像通りです。
|
6
5
|
実行するとHello World と表示されます。
|
6
|
+
状況は下の通りです。
|
7
|
+
|
8
|
+
<Main Activity.java>
|
7
|
-
|
9
|
+
```package com.example.myapplication2;
|
10
|
+
|
11
|
+
import android.support.v7.app.AppCompatActivity;
|
12
|
+
import android.os.Bundle;
|
13
|
+
|
14
|
+
public class MainActivity extends AppCompatActivity {
|
15
|
+
|
16
|
+
public static void main(String[] args){
|
17
|
+
int A;
|
18
|
+
A = 00;
|
19
|
+
if (A == 00) {
|
20
|
+
System.out.println("総記");
|
21
|
+
}
|
22
|
+
else if (A == 01) {
|
23
|
+
System.out.println("百科事典");
|
24
|
+
}
|
25
|
+
if (A == 02) {
|
26
|
+
System.out.println("年鑑・雑誌");
|
27
|
+
}
|
28
|
+
else if (A == 04) {
|
29
|
+
System.out.println("情報科学");
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
```
|
34
|
+
<activity_main.xml>
|
35
|
+
```<?xml version="1.0" encoding="utf-8"?>
|
36
|
+
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
37
|
+
xmlns:app="http://schemas.android.com/apk/res-auto"
|
38
|
+
xmlns:tools="http://schemas.android.com/tools"
|
39
|
+
android:layout_width="match_parent"
|
40
|
+
android:layout_height="match_parent"
|
41
|
+
tools:context=".MainActivity">
|
42
|
+
|
43
|
+
<TextView
|
8
|
-
|
44
|
+
android:layout_width="wrap_content"
|
45
|
+
android:layout_height="wrap_content"
|
46
|
+
app:layout_constraintBottom_toBottomOf="parent"
|
47
|
+
app:layout_constraintLeft_toLeftOf="parent"
|
48
|
+
app:layout_constraintRight_toRightOf="parent"
|
49
|
+
app:layout_constraintTop_toTopOf="parent" />
|
50
|
+
|
51
|
+
</android.support.constraint.ConstraintLayout>
|
52
|
+
```
|
1
ソースコードと実行した状態を追記しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,8 @@
|
|
1
1
|
###android studio は初心者です。
|
2
2
|
if文のプログラムを動かしたいのですが,調べても分からなかったので質問します。
|
3
|
-
条件式は書けているですが,動きません。初歩的なことで申し訳ないのですが,教えてください。
|
3
|
+
条件式は書けているですが,動きません。初歩的なことで申し訳ないのですが,教えてください。
|
4
|
+
|
5
|
+
状況は下の画像通りです。
|
6
|
+
実行するとHello World と表示されます。
|
7
|
+

|
8
|
+

|