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.

版权声明:本文为博主原创文章,未经博主允许不得转载。

最新文章

  1. RMS:Microsoft Office检测到您的信息权限管理配置有问题。有关详细信息,请与管理员联系。(转)
  2. kafka性能参数和压力测试揭秘
  3. 洛谷P1220关路灯[区间DP]
  4. WCF Security(转载)
  5. Ubuntu下配置L2TP
  6. Sqlserver Sql Agent Job 只能同时有一个实例运行
  7. samba配置smb.conf
  8. char与byte差异
  9. php memcached+Mysql(主从)
  10. Docker跨主机网络——overlay
  11. Python数据结构应用2——Queue
  12. Flume1.9.0的安装、部署、简单应用(含分布式、与Hadoop3.1.2、Hbase1.4.9的案例)
  13. POM文件分析记
  14. python练习七—P2P下载
  15. Confluence 6 为空白空间重置原始默认内容
  16. java模式:建造者模式
  17. [No0000F5]C# 类(Class)
  18. php实现网站四则运算。
  19. 【Cmd】那些年,我们迷恋的cmd命令(一)
  20. VUX

热门文章

  1. js获取单选button的值
  2. Python - 字典(dict)删除元素
  3. poj 2480 Longge's problem 积性函数性质+欧拉函数
  4. postgresql 查看单个表大小
  5. android图像处理(3)底片效果
  6. Java循环链表实现约瑟夫环(搬运)
  7. gomail发送附件
  8. JavaScript--Module模式
  9. [转]Accept-Encoding
  10. 通过no-gui模式运行jmeter脚本与生成报告