如果我理解正确
Random ran = new Random();
String[] ButtonText = null;
Resources res = getResources();
ButtonText = res.getStringArray(R.array.ButtonText_array);
String strRandom = ButtonText[ran.nextInt(ButtonText.length)];
System.out.println("Random string is : "+strRandom);
是一种获取我的字符串数组项并将它们按随机顺序排列的方法,现在我想用 strRandom 中的单个项设置几个按钮的 setText。下面是一个按钮的setText
Button gm1 = (Button) findViewById(R.id.gm1);
gm1.setText();
但我不知道如何将 strRandom 项目放入 setText 部分,因为我不需要它显示我需要在此处更改的内容。
System.out.println("Random string is : "+strRandom);