ViewFlipper VS片段 [英] ViewFlipper vs Fragments

查看:148
本文介绍了ViewFlipper VS片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个ViewFlipper那一堆意见(页)之间的翻转与我的数据的活动。

I have an Activity with a ViewFlipper that flips between a bunch of views (pages) with my data.

我正在考虑使用的片段API,以我的观点之间进行切换。这样做有什么好处?

I am considering of using the fragments API to switch between my views. What are the benefits of doing so?

我可以看到通过使用片段,因为ViewFlipper基本上切换可视性标志和片段实际上替换为你添加视图层次提高性能/删除它们?

Could I see a performance gain by using fragments since the ViewFlipper essentially toggles the visibility flags and fragments actually replace the view hierarchy as you add/remove them?

有人可以给我们更多的了解一下吗?

Can someone give us more insight on this?

谢谢!

推荐答案

一个片段重新presents行为或用户界面中的活动的一部分。您可以将多个片段在一个活动建立一个多窗格UI和重用在多个活动的片段。你可以把一个片段作为一个活动,它有自己的生命周期的一个模块化部分,接收自己的输入事件,并且可以添加或活动运行时删除(有点像一个子活动,你可以重用在不同的活动)。

A Fragment represents a behavior or a portion of user interface in an Activity. You can combine multiple fragments in a single activity to build a multi-pane UI and reuse a fragment in multiple activities. You can think of a fragment as a modular section of an activity, which has its own lifecycle, receives its own input events, and which you can add or remove while the activity is running (sort of like a "sub activity" that you can reuse in different activities).

一个片段,必须始终嵌入在活动和片段的生命周期直接影响主机活动的生命周期。例如,当活动暂停,所以是在它的所有片段,并且当活动被破坏,因此是所有片段。然而,当一个活动运行(这是在恢复生命周期状态),你可以独立操作每个片段,比如添加或删除它们。当您执行这样一个片段的交易,你也可以将其添加到这些受该活动,各自回堆在活动条目管理是发生的片段交易的记录回到栈。后退堆栈,用户可以扭转一个片段交易(向后导航),由pressing BACK按钮。

A fragment must always be embedded in an activity and the fragment's lifecycle is directly affected by the host activity's lifecycle. For example, when the activity is paused, so are all fragments in it, and when the activity is destroyed, so are all fragments. However, while an activity is running (it is in the resumed lifecycle state), you can manipulate each fragment independently, such as add or remove them. When you perform such a fragment transaction, you can also add it to a back stack that's managed by the activity—each back stack entry in the activity is a record of the fragment transaction that occurred. The back stack allows the user to reverse a fragment transaction (navigate backwards), by pressing the BACK button.

但ViewFlipper工作在一个单一的活动。 简单ViewAnimator将已添加到它的两个或多个视图之间的动画。只有一个孩子显示的时间。如果需要,可以自动每个孩子之间以规则的间隔翻转。

But ViewFlipper works in an single activity. 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.

这篇关于ViewFlipper VS片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆