teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

MainActivity.javaのコードを載せました

2020/07/11 14:41

投稿

ELEE198
ELEE198

スコア5

title CHANGED
File without changes
body CHANGED
@@ -13,8 +13,8 @@
13
13
  ```
14
14
 
15
15
  ### 該当のソースコード
16
- ![イメージ説明](a51743e57e2edc5651b88faccd8a368b.png)
16
+
17
- ``![イメージ説明](eccd388713de38e5ac6831b235a19ca5.png)`ここに言語名を入力
17
+
18
18
  ソースコード
19
19
  ``
20
20
  package com.example.choice;

1

MainActivity.javaのコードを載せました

2020/07/11 14:41

投稿

ELEE198
ELEE198

スコア5

title CHANGED
File without changes
body CHANGED
@@ -16,8 +16,49 @@
16
16
  ![イメージ説明](a51743e57e2edc5651b88faccd8a368b.png)
17
17
  ``![イメージ説明](eccd388713de38e5ac6831b235a19ca5.png)`ここに言語名を入力
18
18
  ソースコード
19
- ```
19
+ ``
20
+ package com.example.choice;
20
21
 
22
+ import androidx.appcompat.app.AppCompatActivity;
23
+
24
+ import android.os.Bundle;
25
+ import android.view.View;
26
+ import android.widget.EditText;
27
+ import android.widget.TextView;
28
+ import android.widget.Toast;
29
+
30
+ public class MainActivity extends AppCompatActivity {
31
+
32
+ String Answer = "れいめいき";
33
+
34
+
35
+ @Override
36
+ protected void onCreate(Bundle savedInstanceState) {
37
+ super.onCreate(savedInstanceState);
38
+ setContentView(R.layout.activity_main);
39
+
40
+
41
+ }
42
+
43
+ public void btn1(View v){
44
+
45
+ //idを取得
46
+ EditText text = (EditText)findViewById(R.id.textName);
47
+
48
+ String textArea;
49
+ textArea = text.getText().toString();
50
+
51
+
52
+
53
+ //入力された文字があっていればtoastを表示
54
+ if (textArea == Answer) {
55
+ Toast.makeText(this, "correct", Toast.LENGTH_LONG).show();
56
+ }
57
+
58
+
59
+ }
60
+ }
61
+
21
62
  ### 試したこと
22
63
 
23
64
  ここに問題に対して試したことを記載してください。