开发者

Android Random Text Widget

I'm a beginner in Android programming.

I'm wondering .. what would the code in the class开发者_如何学Python look like for a widget that simply displays a random string every once in a while (from like a list of 10 strings)?

I understand the rest of how to make the widget, just not the class.

Thanks!


Well first of all you will need to refer to using the Java Random class

You would start off by gaining access to the random class by

 Random randomGenerator = new Random();

Next you will need to get references to the string by a number for each string. The Random class link should help with that. Also Check here

You would then loop the method using for().

Its a pretty simple concept just takes a little bit of logic.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜