• android.support.v4.app.Fragment vs android.app.Fragment 的区别


    android.support.v4.app.Fragment vs android.app.Fragment 的区别

    我开过平板相关应用,用了Fragment来处理。后来重新开发另外一个应用,直接引用了原来布局和代码,

    我用的是android.support.v4.app.fragment居然死活通过。总是报错
    “android.view.InflateException: Binary XML file line #7: Error inflating class fragment”

    往下推还有提示
    "Trying to instantiate a class cn.bluedrum.phone.CallPad that is not a Fragment"
    at android.app.Fragment.instantiate(Fragment.java:585)

    原来过的程序,现在不行,后来仔细看Android调用是android.app.Fragment的代码。后来把类改名Android.app.Fragment可以正常运行。但是不对啊,原来可以运行啊。后来解决问题,是细节上小问题,特此一记

    一. android.app.Fragment的用法

    android.app.Fragment 兼容的最低版本是android:minSdkVersion="11" 即3.0版
    这样想支持较低版本比较难。

    在Activity中找Fragment 用 可以用Activity 直接使用Fragment

    二.android.support.v4.app.Fragment

    android.support.v4.app.Fragment 兼容的最低版本是android:minSdkVersion="4" 即1.6版
    在Activity中找Fragment 用 fragment android.support.v4.app.Fragment 需要引入包android-support-v4.jar

    使用android.support.v4.app.Fragment必须要在FragmentActivity 里使用!开始的错误在Activity类中使用Fragment造成错误

  • 相关阅读:
    httpd-2.2 配置及用法完全攻略
    在 Ubuntu 16.04 上安装 LEMP 环境之图文向导
    Zookeeper集群搭建
    smem – Linux 内存监视软件
    X.Org可能将失去它的域名x.org
    Docker 容器测试全探索
    Unix操作系统中UUCP知识详细讲解
    常用的Git Tips
    Unix操作系统中UUCP知识详细讲解
    将博客搬至CSDN
  • 原文地址:https://www.cnblogs.com/soonfly/p/4760992.html
Copyright © 2020-2023  润新知