質問編集履歴
1
ついか
test
CHANGED
File without changes
|
test
CHANGED
@@ -245,3 +245,89 @@
|
|
245
245
|
</resources>
|
246
246
|
|
247
247
|
```
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
###
|
252
|
+
|
253
|
+
成功したコード
|
254
|
+
|
255
|
+
OmikujiActivity.java
|
256
|
+
|
257
|
+
```
|
258
|
+
|
259
|
+
package jp.wings.nikkeibp.omikuji;
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
import android.app.Activity;
|
264
|
+
|
265
|
+
import android.os.Bundle;
|
266
|
+
|
267
|
+
import android.util.Log;
|
268
|
+
|
269
|
+
import android.view.View;
|
270
|
+
|
271
|
+
import android.widget.Button;
|
272
|
+
|
273
|
+
import android.widget.ImageView;
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
public class OmikujiActivity extends Activity{
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
@Override
|
282
|
+
|
283
|
+
protected void onCreate(Bundle savedInstanceState) {
|
284
|
+
|
285
|
+
super.onCreate(savedInstanceState);
|
286
|
+
|
287
|
+
setContentView(R.layout.omikuji);
|
288
|
+
|
289
|
+
Button button1 = findViewById(R.id.button1);
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
button1.setOnClickListener(new View.OnClickListener() {
|
294
|
+
|
295
|
+
@Override
|
296
|
+
|
297
|
+
public void onClick(View v) {
|
298
|
+
|
299
|
+
// ボタンを押したときのコード
|
300
|
+
|
301
|
+
ButtonClick(v);
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
}
|
306
|
+
|
307
|
+
});
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
public void ButtonClick(View v)
|
314
|
+
|
315
|
+
{
|
316
|
+
|
317
|
+
ImageView image = new ImageView(this);
|
318
|
+
|
319
|
+
image.setImageResource(R.drawable.daikiti);
|
320
|
+
|
321
|
+
setContentView(image);
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
}
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
```
|