[android-developers] I can't show random images in the ImageView
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+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home