How can I generate a random number in a certain range?

后端 未结 9 1878
抹茶落季
抹茶落季 2020-12-04 23:25

How can I create an app that generates a random number in Android using Eclipse and then show the result in a TextView field? The random number has to be in a r

9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-04 23:48

    " the user is the one who select max no and min no ?" What do you mean by this line ?

    You can use java function int random = Random.nextInt(n). This returns a random int in range[0, n-1]).

    and you can set it in your textview using the setText() method

提交回复
热议问题