1、深圳达内 Android 开发学习 Random 随机数一个随机数生成器,在首页不断变化,可以设置范围。random.java?1234567891011121314151617181920212223package zhang.random;import android.app.Activity;import android.app.AlertDialog;import android.content.Intent;import android.os.Bundle;import android.os.Handler;import android.view.Menu;import androi
2、d.view.MenuItem;import android.view.View;import android.widget.Button;import android.widget.TextView;public class random extends Activityprotected void onResume() super.onResume();private Button start;private Button stop;private TextView show;private Handler handler;private Runnable update;private i
3、nt i;public void onCreate(Bundle savedInstanceState) super.onCreate(savedInstanceState);setContentView(R.layout.random_main);/layout filestart=(Button)findViewById(R.id.start);stop=(Button)findViewById(R.id.stop);show=(TextView)findViewById(R.id.show);handler =new Handler();update = new Runnable()pu
4、blic void run()Intent intent= getIntent();int value = intent.getIntExtra(“max“, 100);i = Integer.valueOf(int) (Math.random()*value);/获得24252627282930313233343536373839404142434445一个随机数if(value 10 & value 100 & value 1000 & value 2324252627282930设置布局?12345678910111213141516174041String.xml?12345678910111200Random退出关于#ffffff设置输入最大值:确定返回By:没落凄凉nQQ :270615838咨询更多信息,登陆深圳达内官方网站:咨询电话:0755-29558210咨询地址:深圳市宝安区西乡大道宝源路 F518 时尚创意园 F2 栋 110