您的位置:首页 > 移动开发 > Android开发

Android:Fragment 初步之旅 随记一

2015-12-14 22:05 429 查看
Fragment 初步之旅
1)

Activity+Window+View+Fragment
Activity:看成房子
Window:看成窗口
View:可以看成窗口上View
Fragment:可以初步看View+CycleLife,依附在Activity上

对Fragment操作:add,remove,replace,hide,show,...

2)

Fragment 官方表达:

A Fragment represents a behavior or a portion of user interface in an Activity.

A Fragment must always be embedded in an activity and the fragment's lifecycle is directly affected by the host activity's lifecycle.
3)静态的Fragment 创建
1) 新一个LeftFragment extends Fragment(v4)
2) 为Fragment 写个布局文件
3) Activity的布局文件可以通过:<fragment name="" />
注意:Activity 需要继承 FragmentActivity
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: