The question is more about android's memory allocation. I have a ViewFlipper with several views each with an image on background. I just want to know if ViewFlipper loads all of it's views images and thus it uses too much memory. This part is about ViewFlipper initialization
bgFlipper = (ViewFlipper) findViewById(R.id.bgFlipper);
int bgLayouts[] = new int[]{ R.layout.bg1, R.layout.bg2,R.layout.bg3,R.layout.bg4,...R.layout.bg100500}; // :)
for (int i = 0;i<bgLayouts.length; i++)
bgFlipper.addView(inflater.inflate(bgLayouts[i], null));
So the question is do I need to add views dynamically on the fly or ViewFlipper already does it for me and I shouldn't worry about those bitmaps on its views backgrounds ie memory allocations?
Yes, The ViewFlipper loads every child view it has the moment it layout itself. So for example, if your ViewFlipper has multiple Fragments with Bitmaps created on onCreate(), they all will be created, no matter if they are visible at the moment. So you better watch out, you can easily create OutOfMemoryError in that case.