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

質問編集履歴

2

記事の追加

2017/07/18 13:28

投稿

riroholll
riroholll

スコア57

title CHANGED
File without changes
body CHANGED
@@ -213,4 +213,18 @@
213
213
 
214
214
  ![イメージ説明](373540f11d2c418af6bc34c579976f4c.png)
215
215
 
216
- このようなエラーが発生します
216
+ このようなエラーが発生します
217
+
218
+
219
+ 更新
220
+ アルゴリズム的には
221
+
222
+ if checkbox2 =tree
223
+ の時
224
+ system.out.print(a)
225
+
226
+ else if checkbox3=tree
227
+
228
+ system.out.print(b)
229
+
230
+ みたいなプログラムを書きたいと思っている

1

修正

2017/07/18 13:28

投稿

riroholll
riroholll

スコア57

title CHANGED
File without changes
body CHANGED
@@ -126,4 +126,91 @@
126
126
 
127
127
  こう書くとエラーになります。
128
128
 
129
- どのように直せばよいのでしょうか?
129
+ どのように直せばよいのでしょうか?
130
+
131
+ 追加
132
+ ```ここに言語を入力
133
+ package com.example.askad.myapplication;
134
+
135
+ import android.app.Activity;
136
+ import android.content.Intent;
137
+ import android.os.Bundle;
138
+ import android.view.View;
139
+ import android.widget.Button;
140
+ import android.widget.CheckBox;
141
+
142
+
143
+ public class SubActivity extends Activity {
144
+
145
+ @Override
146
+ protected void onCreate(Bundle savedInstanceState) {
147
+ super.onCreate(savedInstanceState);
148
+ setContentView(R.layout.activity_sub1);
149
+
150
+
151
+ final CheckBox CheckBox = (CheckBox)findViewById(R.id.checkBox2);
152
+ CheckBox.setOnClickListener(new View.OnClickListener(){
153
+
154
+ @Override
155
+ public void onClick(View v) {
156
+
157
+ if(CheckBox.isChecked() == true) {
158
+
159
+
160
+ Button Button = (Button) findViewById(R.id.button);
161
+ Button.setOnClickListener(new View.OnClickListener() {
162
+ @Override
163
+ public void onClick(View v) {
164
+ Intent intent = new Intent(getApplication(), MainActivity.class);
165
+ startActivity(intent);
166
+ }
167
+ });
168
+ }
169
+ else {
170
+
171
+ final CheckBox CheckBox = (CheckBox)findViewById(R.id.checkBox3);
172
+ CheckBox.setOnClickListener(new View.OnClickListener(){
173
+
174
+ @Override
175
+ public void onClick(View v) {
176
+
177
+ if(CheckBox.isChecked() == true) {
178
+
179
+
180
+ Button Button = (Button) findViewById(R.id.button);
181
+ Button.setOnClickListener(new View.OnClickListener() {
182
+ @Override
183
+ public void onClick(View v) {
184
+ Intent intent = new Intent(getApplication(), MainActivity.class);
185
+ startActivity(intent);
186
+ }
187
+ });
188
+ }
189
+
190
+
191
+
192
+ }
193
+
194
+
195
+ }
196
+ });
197
+ }
198
+ }
199
+
200
+
201
+
202
+
203
+
204
+
205
+
206
+
207
+
208
+
209
+
210
+
211
+ ```
212
+ に変更すると
213
+
214
+ ![イメージ説明](373540f11d2c418af6bc34c579976f4c.png)
215
+
216
+ このようなエラーが発生します