Fragment comments
来源:互联网 发布:linux java开发 编辑:程序博客网 时间:2024/05/17 04:22
1. Fragment
实现一个UI, 可在activity之间共享
实现一个逻辑
2. Fragment 在activity的控制下,没有activity不能活动
3. 引入Fragment要解决的问题
Fragment和activity的通信
Fragment之间的通信
Fragment 和back stack
Fragment和activty的action bar
4. Fragment的生命周期
The core series of lifecycle methods that are called to bring a fragment up to resumed state (interacting with the user) are:
onAttach(Activity)
called once the fragment is associated with its activity.onCreate(Bundle)
called to do initial creation of the fragment.onCreateView(LayoutInflater, ViewGroup, Bundle)
creates and returns the view hierarchy associated with the fragment.
每次fragment被切换出去又切换回来,会重新调用此函数。目的可能是为节省内存
onActivityCreated(Bundle)
tells the fragment that its activity has completed its ownActivity.onCreate()
.
每次fragment被切换出去又切换回来,不会调用此函数
onViewStateRestored(Bundle)
tells the fragment that all of the saved state of its view hierarchy has been restored.
每次fragment被切换出去又切换回来,不会调用此函数
onStart()
makes the fragment visible to the user (based on its containing activity being started).onResume()
makes the fragment begin interacting with the user (based on its containing activity being resumed).
As a fragment is no longer being used, it goes through a reverse series of callbacks:
onPause()
fragment is no longer interacting with the user either because its activity is being paused or a fragment operation is modifying it in the activity.onStop()
fragment is no longer visible to the user either because its activity is being stopped or a fragment operation is modifying it in the activity.onDestroyView()
allows the fragment to clean up resources associated with its View.onDestroy()
called to do final cleanup of the fragment's state.onDetach()
called immediately prior to the fragment no longer being associated with its activity.
5. Fragment和Activity的关联
1。在Activity的layout文件中,fragment象一个view一样被使用,但是他不是view,每个Fragment应有不同的id
2。动态使用FragmentManager增加 ,这方法可加入一个无UI的Fragment
Fragment通过getActivity获得相关联的Activity
6。 FragmentManager,Fragment的管理者
Activity的Fragment通过FragmentManager管理。
查询和pop stack的管理
增加和删除,替换,fragment, fragment显示的控制
?attach/detach
7。 Fragment和activity的action bar
Fragment
setHasOptionsMenu()
onCreateOptionsMenu()
onOptionsItemSelected()
onCreateContextMenu()
onContextItemSelected()
菜单项加在最后
7。 Fragment的参数传递
setArguments(Bundle args)
- Fragment comments
- Comments
- Comments
- struts2 comments
- Column Comments
- django comments
- Context comments
- permission comments
- Service comments
- Cursor comments
- Funny Comments
- Menu comments
- Setting comments
- Dialog comments
- draw comments
- ASyncTask comments
- RFC(Request For Comments)
- comments macro in vs2008
- Arduino和Android通过OTG 通信
- 【虫师--系列01】在做性能测试之前需要知道什么
- 面向对象的设计模式(六),状态模式
- C++11中的std::bind
- POJ 3621 Sightseeing Cows(01分数规划+二分+Spfa判负环)
- Fragment comments
- 例说如何编译android模块
- android Graphics(一):概述及基本几何图形绘制
- JNDI 理解
- ASCII、ANSI、MBCS、UNICODE字符集
- 自定义快速索引,仿微信好友查询列表
- linux mysql设置开机启动
- 【虫师--系列02】在做性能测试之后需要知道些什么
- IOS开发之----两种保存用户名和密码实现记住密码库