是否可以重用 ViewFlipper 中的视图?
可能是一个愚蠢的问题。但是,是否可以重用 viewflipper 中的视图? 现在,我在视图翻转器中有三个图像视图。是否可以有一个图像视图并将源更改为它?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想自己处理簿记,您可以重用视图。然而,取景器至少需要 2 个视图。来自 Android ViewFlipper 文档:
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:
您必须从
ViewFlipper
中删除ImageView
,然后将其放在其他地方。您不能同时将其放入两个ViewGroup
中(您将得到一个异常,即视图已经有父级)。但这是您根本不需要做的开销。只需创建新的 ImageView 并使用它们即可。 ImageView 的内存消耗部分不是对象本身,而是它绘制的位图,所以我真的建议阅读 这篇文章。
You would have to remove the
ImageView
from theViewFlipper
and then put it somewhere else. You can't put it into twoViewGroup
s 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
ImageView
s and use them. The memory consuming part of anImageView
is not the object itself but the bitmap it draws so I really recommend to read this article.