I want to create a dynamic number of ImageViews in Android. But to display these ImageViews I have to create them in the main.xml (Am I right?) Is there a way to display the ImageViews without creating them in the main.xml?
You can create them dynamically like this:
ImageView image=new ImageView(this);
and to set image in this dynamically created view use:
image.setImageResource(R.drawable.yourimage);
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