Android编程知识点2- 线性布局,随机数

基本框架

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"> //方向horizontal
</LinearLayout>

 

产生指定范围的随机数

以产生[10,99]范围内的随机数为例

int min=10;
int max=99;
Random random = new Random();
int num = random.nextInt(max)%(max-min+1) + min;
posted @ 2018-11-15 19:32  清心lh  阅读(99)  评论(0编辑  收藏  举报