Fragment之一:基本原理
来源:互联网 发布:java float精度 编辑:程序博客网 时间:2024/06/04 18:48
1、低版本API对Fragment的支持
Fragment必须被加载进Acitivity中,才能呈现。而在低于3.0版本的API中,由于不存在Fragment,因此必须使用support包:
(1)对于1.6(API=4)及以上版本:
创建Fragment时,应该继承android.support.v4.app.Fragment;
创建Activity时,应该继承android.support.v4.app.FragmentActivity;
(2)对于2.1(API=7)及以上版本:(为同时支撑ActionBar)
创建Fragment时,应该继承android.support.v4.app.Fragment;(这个还需要确认一下)
创建Activity时,应该继承android.support.v7.app.ActionBarActivity
(3)他们之间的关系为:
java.lang.Object
↳ android.content.Context
↳ android.content.ContextWrapper
↳android.view.ContextThemeWrapper
↳android.app.Activity
↳android.support.v4.app.FragmentActivity
↳android.support.v7.app.ActionBarActivity
2、addToBackStack()
Keep in mind that when you perform fragment transactions, such as replace or remove one, it's often appropriate to allow the user to navigate backward and "undo" the change. To allow the user to navigate backward through the fragment transactions, you must call addToBackStack() before you commit the FragmentTransaction.
3、Fragment之间的通信
To allow a Fragment to communicate up to its Activity, you can define an interface in the Fragment class and implement it within the Activity.
- Fragment之一:基本原理
- Fragment之一:基本原理
- Android Fragment基本原理
- Loader之一:基本原理
- Hadoop基本原理之一:MapReduce
- Hadoop基本原理之一:MapReduce
- Loader之一:基本原理
- 卷积神经网络之一:基本原理
- Impala实践之一:基本原理
- Fragment之一:Fragment入门
- Fragment之一:Fragment入门
- Flink之一 Flink基本原理介绍
- Java HashMap笔记之一:基本原理
- 一步一步学习Fragment之一
- Cocoa基本原理指南之一 - Cocoa框架
- Cocoa基本原理指南之一 - Cocoa框架
- Android Fragment学习之一、Fragment生命周期
- Fragment之一:封装及生命周期
- ecshop 去版权
- redis简介
- Redis 2.2.* 到 2.4.*升级方案
- poj 1511 -- Invitation Cards
- poj1025
- Fragment之一:基本原理
- python 专题九 POP IMAP 邮件收取
- “Invalid layout of preloaded class”问题解决
- 关于浏览器的好文章
- 解决union慢问题(ORA-17410)
- 测试点总结(不断更新中)
- Linux内核启动过程分析
- Pay close attention to manage multiple resource in one object - C++11, 24 of n
- WPF中的ListBox的用法