I am trying to create a card game for an android app (for practice) and I was wondering how would I upload random cards into the players hand? I have the GUI implemented and I think I would need something along the lines of a typedarray and
((ImageView)findViewById(R.id.textView18)).setImageResource(R.drawable.1c);
Am I moving along the right tracks with this?
You can get random images like this:
int[] images = {R.drawable.img1,R.drawable.img2,R.drawable.img3,R.drawable.img4};
Random rand = new Random();
imageView.setImageResource(images[rand.nextInt(images.length)]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With