且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何生成一个随机数,然后显示在屏幕上?

更新时间:2023-02-06 11:39:51

Android的文档非常出色。下面是一个Hello World应用程序:

Android's documentation is excellent. Here's a hello world app:

http://developer.android.com/guide/tutorials/hello-world.html

只要修改

tv.setText("Hello, Android");

tv.setText("Random Number: " + Math.random());

和确保导入数学库(如果你使用Eclipse,按Ctrl + Shift + O)。

and make sure to import the Math library (if you're using eclipse, hit Ctrl+Shift+O).