Android的随机对象 [英] Android random object

查看:85
本文介绍了Android的随机对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我米开发在android系统纸牌游戏。
我需要通过动画按钮,点击它应该是随机卡显示三张牌出的52张牌。

I m developing a card game in android. i need to show three cards out of 52 cards by button click through animation which should be random cards.

那么,如何能做到这一点?

so how can i do that?

推荐答案

如果你是存储卡在Array或ArrayList的,你可以很容易地使用生成的随机小号nextInt(52)方法。这种方法会给你0和51之间的随机int和那么你可以使用它作为索引拿到卡淘汰之列。

If you are storing the cards in an Array or ArrayList you could easily generate a random number using Randoms nextInt(52) method. This method will give you a random int between 0 and 51 and you can then use this as the index to get the card out of the list.

有关这取决于你想要什么样的动画,什么样的图形和视图你的动画。看一看在动画包并与回来一个更具体的问题,我们会很乐意回答这个问题。

For the animation that depends on what kind of animation you want and what kind of graphics and Views you have. Have a look at the animation package and come back with a more specific question we would be happy to answer it.

这篇关于Android的随机对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆