質問編集履歴

1

ソース追加

2015/07/15 16:12

投稿

kimura
kimura

スコア59

test CHANGED
File without changes
test CHANGED
@@ -15,3 +15,65 @@
15
15
 
16
16
 
17
17
  何卒よろしくお願い致します。
18
+
19
+
20
+
21
+ すいません
22
+
23
+
24
+
25
+ 下記が抜粋ですがソースです
26
+
27
+
28
+
29
+ よろしくお願い致します
30
+
31
+
32
+
33
+ public class MainActivity extends AppCompatActivity {
34
+
35
+
36
+
37
+ @Override
38
+
39
+ protected void onCreate(Bundle savedInstanceState) {
40
+
41
+ super.onCreate(savedInstanceState);
42
+
43
+ setContentView(R.layout.activity_main);
44
+
45
+ }
46
+
47
+
48
+
49
+ public void getOmikuji(View view) {
50
+
51
+ // textviewの取得
52
+
53
+ TextView tv = (TextView) (TextView) findViewById(R.id.myTextView);
54
+
55
+ String[] results = {
56
+
57
+ "大吉",
58
+
59
+ "吉",
60
+
61
+ "凶"
62
+
63
+ };
64
+
65
+ // 乱数の生成
66
+
67
+ Random randomGenerator = new Random();
68
+
69
+ int num = randomGenerator.nextInt(results.length);
70
+
71
+ // 結果の表示
72
+
73
+ //String result = Integer.toString(num);
74
+
75
+ tv.setText(results[num]);
76
+
77
+ }
78
+
79
+ }