質問編集履歴

1

スクリプトの追加

2021/10/14 06:27

投稿

papas1888
papas1888

スコア6

test CHANGED
File without changes
test CHANGED
@@ -73,3 +73,93 @@
73
73
  }
74
74
 
75
75
  ```
76
+
77
+ ### 10/14追記
78
+
79
+ ```ここに言語を入力
80
+
81
+ public class MainActivity extends AppCompatActivity {
82
+
83
+ Random r = new Random();
84
+
85
+ int reR[]={r.nextInt(100),r.nextInt(100)};//
86
+
87
+
88
+
89
+ @Override
90
+
91
+ protected void onCreate(Bundle savedInstanceState) {
92
+
93
+ super.onCreate(savedInstanceState);
94
+
95
+ setContentView(R.layout.activity_main);
96
+
97
+ }
98
+
99
+
100
+
101
+ public void resultBtn(View v){//(ボタン)ランダムな値を習得してResultアクティビティーへ移動
102
+
103
+ //Random random = new Random();
104
+
105
+ //reR = random.nextInt(100);
106
+
107
+ for(int i=0;i< reR.length;i++){
108
+
109
+ Intent intent = new Intent(this, Result.class);
110
+
111
+ intent.putExtra("result", reR[i]);
112
+
113
+ startActivity(intent);
114
+
115
+ }
116
+
117
+ }
118
+
119
+ }
120
+
121
+ ```
122
+
123
+ ```ここに言語を入力
124
+
125
+ public class Result extends AppCompatActivity {
126
+
127
+ private TextView date;//ガチャの結果
128
+
129
+ private TextView date2;//ガチャの結果2
130
+
131
+ @Override
132
+
133
+ protected void onCreate(Bundle savedInstanceState) {
134
+
135
+ super.onCreate(savedInstanceState);
136
+
137
+ setContentView(R.layout.activity_result);
138
+
139
+
140
+
141
+ date = findViewById(R.id.a);
142
+
143
+ date2 = findViewById(R.id.b);
144
+
145
+ int score = getIntent().getIntExtra("result", 0);
146
+
147
+ if(50>score){
148
+
149
+ date.setText("ノーマル");
150
+
151
+ date2.setText("ノーマル");
152
+
153
+ }else{
154
+
155
+ date.setText("レア");
156
+
157
+ date2.setText("レア");
158
+
159
+ }
160
+
161
+ }
162
+
163
+ }
164
+
165
+ ```