示例我有 3 个按钮
<Button
android:id="@+id/q1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/q2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<Button
android:id="@+id/q3"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
我有如下随机文本
private static final String[] answers = {"a", "b", "c", "Vowel", "d", "e", "f"};
String q = answers[rgenerator.nextInt(answers.length)];
button1.setText(q);
button2.setText(q);
button3.setText(q);
示例我随机开始活动 5 次:
1st activity start random look like: a, c, Vowel
2st activity start random look like: b, Vowel, a
3st activity start random look like: Vowel, e, b
4st activity start random look like: a, e, Vowel
5st activity start random look like: Vowel, b, f
在活动刷新/开始时,所有时间活动开始必须始终将“元音”setText 设置为 3 个按钮中的 1 个。
我真的坚持下去了..