android-Fragment
2015-11-26 21:11
429 查看
Fragment的类型有:DialogFragment;ListFragment;PreferenceFragment
is declared inside fragment A:
in case the activity's process is killed and you need to restore the fragment state when the activity is recreated. You can save the state during the fragment's
and restore it during either
or
不保存当前的Fragment时,使用Fragment.commitAllowingStateLoss()方法
For example, if a news application has two fragments in an activity—one to show a list of articles (fragment A) and another to display an article (fragment B)—then fragment A must tell the activity when a list item is selected so that it can tell fragment B to display the article. In this case, the OnArticleSelectedListenerinterface
is declared inside fragment A:
Fragment A通过Activity传输数据到Fragment B,实现机制:Fragment A定义一个interface,Activity去实现接口,并将返回通知给Fragment B。
将Activity的数据传给Fragment时,可以使用Bundle.
Also like an activity, you can retain the state of a fragment using a Bundle,
in case the activity's process is killed and you need to restore the fragment state when the activity is recreated. You can save the state during the fragment's
onSaveInstanceState()callback
and restore it during either
onCreate(),
onCreateView(),
or
onActivityCreated().
横竖屏切换时,Activity状态的保存。
相关文章推荐
- [Android学习笔记六] Toast 更长时间显示
- android deamon
- Android ListView只加载当前屏幕内的图片(解决list滑动时加载卡顿)
- Mac打开android api doc 慢解决办法
- Android 动画浅谈(二)
- Android adb.exe链接中断 The connection to adb is down, and a severe error has occured.
- Android中防止重复点击的小技巧
- Android asset raw 文件夹的区别深入解析
- Android:shape的使用详解(2)
- 用Kotlin开发Android应用(IV):定制视图和Android扩展
- 转: 加快Android编译速度
- 一个完整的猫眼程序
- android开发步步为营之85:RecyclerView简单使用
- Android xml ListView 的divider属性
- Androidのspinner控件使用
- Android之NDK开发 环境配置
- Android之自定义 ActionBar 上的菜单(Menu)文字颜色
- Android中Parcelable接口用法
- android 围绕中心旋转动画
- android易忽视知识点总结(word版开源下载:8页)