需要优化软件UI,so 沉寂许久之后开始学习界面的课程,把文档直接贴过来自己试着翻译

Fragment作为应用界面的一部分或行为,可通过FragmentManager进行交互。每个Fragment代表一个操作或接口,与活动紧密相关,其生命周期受活动控制。所有Fragment子类需包含公共空构造函数以确保框架正确实例化。

界面第一课:Fragment

A Fragment is a piece of an application's user interface or behavior that can be placed in an Activity. Interaction with fragments is done through FragmentManager, which can be obtained via Activity.getFragmentManager() and Fragment.getFragmentManager().

The Fragment class can be used many ways to achieve a wide variety of results. In its core, it represents a particular operation or interface that is running within a larger Activity. A Fragment is closely tied to the Activity it is in, and can not be used apart from one. Though Fragment defines its own lifecycle, that lifecycle is dependent on its activity: if the activity is stopped, no fragments inside of it can be started; when the activity is destroyed, all fragments will be destroyed.

All subclasses of Fragment must include a public empty constructor. The framework will often re-instantiate a fragment class when needed, in particular during state restore, and needs to be able to find this constructor to instantiate it. If the empty constructor is not available, a runtime exception will occur in some cases during state restore.

Fragment 可以称作是软件界面的一个小片段或是可以放在一个活动里的行为。Fragment的交互通过fragment管理器,可以通过Activity.getFragmentManager()Fragment.getFragmentManager()这两个方法实现。

Fragment这个类可以使用许多方法来获得各种各样的结果。在其核心,它代表了一个大型活动中的一个特定的操作或接口。一个片段和活动密切相关,依赖于活动而存在。尽管片段定义了它自己的生命周期,生命周期取决于其活动:如果活动停止,所有碎片将停止;当活动被摧毁,所有片段将被摧毁。

所有片段的子类必须包括一个公共空构造函数。框架需要时往往会重新实例化一个片段类,尤其是状态恢复时,需要能够找到这个构造函数实例化它。如果空构造函数不可用,在某些情况下状态恢复时会发生异常。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值