开发者

Is it possible to reuse the views in ViewFlipper?

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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜