[英]How to set the text of a TextView from Java
我需要隨機化TextView
的文本。
我知道如何通過以下示例隨機化這些東西:
String[] epicstring={"a", "b", "c", "d", "e"};
Random r=new Random();
int randomnumber= r.nextInt(epicstring.length);
System.out.println(epicstring[randomnumber]);
我想將 output 文本轉換成TextView
,但我該怎么做呢?
TextView textView = (TextView) findViewById(R.id.MyTextView); // use with ID of your TextView
textView.setText(epicstring[randomnumber]);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.