it is a rather simple question. I have 5 imageViews and 5 images in drawable folder. ImageViews are named imageView1
...imageView5
and images are named image1
...image5
I want how can I write the following elegantly:
imageView1.setImageResource(R.drawable.image1)
imageView2.setImageResource(R.drawable.image2)
imageView3.setImageResource(R.drawable.image3)
imageView4.setImageResource(R.drawable.image4)
imageView5.setImageresource(R.drawable.image5)
As you understand, there are not just 5 imageViews, but there are many more and I want to write it in a loop. I am having problems because R.drawable.imageX
is integer not string.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…