欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android生成隨機(jī)數(shù)的方法實(shí)例

 更新時(shí)間:2021年03月22日 11:13:02   作者:你先去買飯  
這篇文章主要為大家詳細(xì)介紹了Android生成隨機(jī)數(shù)的方法實(shí)例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android生成隨機(jī)數(shù)的具體代碼,供大家參考,具體內(nèi)容如下

java文件

package com.example.my_xm_bw_luowei;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

import java.util.Random;

public class MainActivity extends AppCompatActivity {

  private Button bt1;
  private EditText et1;
  private EditText et2;
  private TextView tv;
  private int i=0;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    bt1 = (Button) findViewById(R.id.bt1);
    et2 = (EditText) findViewById(R.id.et2);
    tv = (TextView) findViewById(R.id.tv);
    bt1.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View v) {
        i++;
        String trim2 = et2.getText().toString().trim();
        String s = "";
        Random ran =new Random(System.currentTimeMillis());
        Log.d("aaa", "onClick: "+i);
        for (int i = 0 ; i <1; i++) {
          s = s + "\n" + ran.nextInt(Integer.parseInt(trim2));
        }
        tv.setText(s+"");
        if (i==10){
          tv.setText("直接讓高金玉上 嘻嘻嘻");
        }
      }
    });
  }

}

xml文件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity"
  android:orientation="vertical"
  >

  <Button
    android:text="高金玉"
    android:id="@+id/bt1"
    android:background="#ffffff"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"></Button>
  <EditText
    android:id="@+id/et2"
    android:hint="0-n"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"></EditText>
  <TextView
    android:textColor="#DD0D0D"
    android:textSize="50dp"
    android:id="@+id/tv"
    android:text="0"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"></TextView>
</LinearLayout>

效果圖片

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android開發(fā)之Sqliteopenhelper用法實(shí)例分析

    Android開發(fā)之Sqliteopenhelper用法實(shí)例分析

    這篇文章主要介紹了Android開發(fā)之Sqliteopenhelper用法,實(shí)例分析了SQLiteOpenHelper類操作數(shù)據(jù)庫的相關(guān)技巧,需要的朋友可以參考下
    2015-05-05
  • Android UI 實(shí)現(xiàn)老虎機(jī)詳解及實(shí)例代碼

    Android UI 實(shí)現(xiàn)老虎機(jī)詳解及實(shí)例代碼

    這篇文章主要介紹了Android UI 實(shí)現(xiàn)老虎機(jī)詳解及實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下
    2017-03-03
  • 一文詳解Android?FCM接入

    一文詳解Android?FCM接入

    這篇文章主要為大家介紹了Android?FCM接入詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-03-03
  • Android實(shí)現(xiàn)底部彈窗效果

    Android實(shí)現(xiàn)底部彈窗效果

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)簡單的底部彈窗效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-05-05
  • Android中WebView加載網(wǎng)頁設(shè)置進(jìn)度條

    Android中WebView加載網(wǎng)頁設(shè)置進(jìn)度條

    這篇文章主要為大家詳細(xì)介紹了Android中WebView加載網(wǎng)頁設(shè)置進(jìn)度條的相關(guān)代碼,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-04-04
  • Qt5.12.6配置Android Arm開發(fā)環(huán)境(圖文)

    Qt5.12.6配置Android Arm開發(fā)環(huán)境(圖文)

    本文主要介紹了Qt5.12.6配置Android Arm開發(fā)環(huán)境,文中通過圖文介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-06-06
  • Android幀動(dòng)畫、補(bǔ)間動(dòng)畫、屬性動(dòng)畫用法詳解

    Android幀動(dòng)畫、補(bǔ)間動(dòng)畫、屬性動(dòng)畫用法詳解

    安卓的三種動(dòng)畫,幀動(dòng)畫,補(bǔ)間動(dòng)畫,屬性動(dòng)畫,大家了解多少,知道如何使用嗎?本文就為大家簡單介紹Android幀動(dòng)畫、補(bǔ)間動(dòng)畫、屬性動(dòng)畫的使用方法,需要的朋友可以參考下
    2016-11-11
  • Android中音視頻合成的幾種方案詳析

    Android中音視頻合成的幾種方案詳析

    隨著音視頻領(lǐng)域的火熱,在很多領(lǐng)域(教育,游戲,娛樂,體育,跑步,餐飲,音樂等)嘗試做音視頻功能,下面這篇文章主要給大家介紹了關(guān)于Android中音視頻合成的幾種方案的相關(guān)資料,需要的朋友可以參考借鑒,下面隨著小編來一起看看吧。
    2017-12-12
  • Android自定義控件打造閃閃發(fā)光字體

    Android自定義控件打造閃閃發(fā)光字體

    這篇文章主要為大家詳細(xì)介紹了Android自定義控件打造閃閃發(fā)光字體,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • android自定義組件實(shí)現(xiàn)方法

    android自定義組件實(shí)現(xiàn)方法

    這篇文章主要介紹了android自定義組件實(shí)現(xiàn)方法,實(shí)例分析了Android實(shí)現(xiàn)自定義組件中頁面布局及功能實(shí)現(xiàn)的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-07-07

最新評論