zoukankan      html  css  js  c++  java
  • Fragment之一:基本原理 分类: H1_ANDROID 2013-11-18 14:15 1642人阅读 评论(0) 收藏


    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学习简介与生命周期研究
    POJ 2513 Colored Sticks 【Trie树】
    listView实时更新
    苹果技术支持联系方式
    文件中随机读取行问题
    hdu 4554
    hdu 4556
    离开通讯后就职互联网行业的一些感悟
    HDU1016:Prime Ring Problem
    dbgrideh通用打印
  • 原文地址:https://www.cnblogs.com/lujinhong2/p/4637357.html
Copyright © 2011-2022 走看看