I tried it out and sadly n is 0 everytime, but I don't know why.

On aug. 6, 17:23, Miguel Morales <therevolti...@gmail.com> wrote:
> Add some logging so that you can see what n is.
> Then find out why it's not generating a random number.
>
>
>
>
>
>
>
>
>
> On Sat, Aug 6, 2011 at 8:33 AM, Zwiebel <hunzwie...@gmail.com> wrote:
> > Nice day!
>
> > I tried to show random images in my application in an ImageView. I
> > tried this code:
>
> > public class r extends Activity{
>
> >        ImageView secret;
> >        @Override
> >        protected void onCreate(Bundle savedInstanceState) {
> >                // TODO Auto-generated method stub
> >                super.onCreate(savedInstanceState);
> >                setContentView(R.layout.r);
>
> >                TextView txt = (TextView) findViewById(R.id.txt);
> >                secret = (ImageView) findViewById(R.id.secret);
>
> >                Runnable r1 = new Runnable() {
>
> >                        @Override
> >                        public void run() {
> >                                // TODO Auto-generated method stub
> >                                int imageArr[] = new int[3];
> >                                imageArr[0] = R.drawable.r1_mirror;
> >                                imageArr[1] = R.drawable.s1_mirror;
> >                                imageArr[2] = R.drawable.p2_mirror;
> >                                int n = (int) Math.random()*3;
> >                                secret.setImageResource(imageArr[n]);
>
> >                        }
> >        };
>
> >                secret.postDelayed(r1, 5000);
> >        }
> > }
>
> > But it only show the r1_mirror image, everytime, when I start my
> > application in the emulator. What I made bad? I thought that it will
> > working, but.
>
> > Thanks for any helps
>
> > --
> > 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+unsubscr...@googlegroups.com
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> --
> ~ Jeremiah:9:23-24
> Android 2D MMORPG:http://solrpg.com/, http://www.youtube.com/user/revoltingx

-- 
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to