Android 安卓短语o-matic
我想把这个小程序移植到Android上,事情是Android的im level basic-1,这个程序所做的是随机创建一个从数组字符串中提取的短语。我知道如何制作一个按钮来显示布局资源中的xml,但这只适用于不变的文本视图,请告诉我要显示从字符串数组中随机生成的字符串,需要执行哪些步骤 下面是代码(头先java):Android 安卓短语o-matic,android,Android,我想把这个小程序移植到Android上,事情是Android的im level basic-1,这个程序所做的是随机创建一个从数组字符串中提取的短语。我知道如何制作一个按钮来显示布局资源中的xml,但这只适用于不变的文本视图,请告诉我要显示从字符串数组中随机生成的字符串,需要执行哪些步骤 下面是代码(头先java): 如果我问如何从字符串设置TextView的文本会更好吗?如果不是,你能帮我一个忙吗?你试过setText?大多数hello,world应用程序,加上setText存在的知识,应该足
如果我问如何从字符串设置TextView的文本会更好吗?如果不是,你能帮我一个忙吗?你试过
setText
?大多数hello,world应用程序,加上setText
存在的知识,应该足以让您开始。有特定问题后,请重试:)
public class PhraseOMatic
{
public static void main (String[] args)
{
String[] wordListOne = {"24/7", "multi-tier", "30,OOO foot", "B-to-B" , "win-win" , "frontend", "web- based" , "pervasive", "smart", "sixsigma", "critical-path", "dynamic"};
String[] wordListTwo = {"empowered", "sticky", "value-added", "oriented", "centric", "distributed", "clustered", "branded", "outaide-the-box", "positioned", "networked", "focused", "leveraged", "aligned", "targeted", "shared", "cooperative", "accelerated"};
String[] wordListThree = {"process", "tipping-point", "solution", "architecture", "core competency", "strategy", "mindshare", "portal", "space", "vision", "paradigm", "session"};
// find out how many words are in each list
int oneLenqth = wordListOne.length;
int twoLength = wordListTwo.length;
int threeLength = wordListThree.length;
// generate .... random numbers
int randl = (int) (Math.random() * oneLenqth);
int rand2 = (int) (Math.random() * twoLength);
int rand3 = (int) (Math.random() * threeLength);
//now build a phrase
String phrase = wordListOne[randl] + " " + wordListTwo[rand2] + " " + wordListThree[rand3];
// print out the phrase
System.out.println("What we need is a " + phrase);
}
}