Take the 2-minute tour ×

May be a dumb Question.But still, is it possible to reuse the views in viewflipper? Now,i have three imageviews in a viewflipper.is it possible to have a single imageview and change the source to it?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You can probably reuse view if you want to take care of the bookkeeping your self. However the viewflipper requires at least 2 views. From the Android ViewFlipper Docs:

Simple ViewAnimator that will animate between two or more views that have been added to it. Only one child is shown at a time. If requested, can automatically flip between each child at a regular interval.

share|improve this answer
The ViewFlipper doesn't insist to contain at least two views. It just doesn't make sense to have a ViewFlipper with on child only or even zero (like for any layout view). –  Knickedi Oct 3 '11 at 23:45

You would have to remove the ImageView from the ViewFlipper and then put it somewhere else. You can't put it into two ViewGroups at the same time (you'll get an exception that the view has already a parent).

But this is an overhead which you simply don't need to do. Simply create new ImageViews and use them. The memory consuming part of an ImageView is not the object itself but the bitmap it draws so I really recommend to read this article.

share|improve this answer

Your Answer


