Saturday, August 6, 2011

Re: [android-developers] Re: I can't show random images in the ImageView

On Sun, Aug 7, 2011 at 2:38 AM, Zwiebel <hunzwiebel@gmail.com> wrote:
> I tried it out and sadly n is 0 everytime, but I don't know why.
>

Reading the docs usually helps:


public static double random()

Returns a double value with a positive sign, greater than or equal
to 0.0 and less than 1.0.


You are casting to int, so it's always going to be zero. What you need is
java.util.Random.nextInt().

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment