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造成错误

android.support.v4.app.Fragment vs android.app.Fragment 的区别的更多相关文章

  1. android.support.v4与Android.support.v7

    Android提供了android.support.v4和android.support.v7两个库,以便低版本API可以使用高版本API的功能. Fragment(碎片)类,是在Android 3. ...

  2. android studio: Rejecting re-init on previously-failed class java.lang.Class<android.support.v4.view.ViewCompat$OnUnhandledKeyEventListenerWrapper>: java.lang.NoClassDefFoundError: Failed resolution o

    今天在运行部署项目时logcat弹出下列错误: -- ::-/? E/Zygote: v2 -- ::-/? I/libpersona: KNOX_SDCARD checking this -- :: ...

  3. android.support.v4.widget.DrawerLayout使用

    activity_main.xml布局如下: <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas ...

  4. import android.support.v4或者import android.support.v7提示导入错误解决办法

    转自:  http://blog.csdn.net/forandever/article/details/37655139 在使用Eclipse开发andriod程序时,程序中提示import and ...

  5. 在布局中使用android.support.v4.app.Fragment的注意事项

    1.Activity必须继承android.support.v4.app.FragmentActivity 2.fragment标签的name属性必须是完全限定包名,如下: <LinearLay ...

  6. android.support.v4.app.Fragment和android.app.Fragment区别

    1.最低支持版本不同 android.app.Fragment 兼容的最低版本是android:minSdkVersion="11" 即3.0版 android.support.v ...

  7. Attempt to write to field 'android.support.v4.app.FragmentManagerImpl android.support.v4.app.Fragment.mFragmentManager' on a null object reference

    E/AndroidRuntime﹕ FATAL EXCEPTION: mainProcess: org.example.magnusluca.drawertestapp, PID: 3624java. ...

  8. Android fragment切换后onresume时报 Attempt to write to field 'int android.support.v4.app.Fragment.mNextAnim'

    动态加载fragment以后,调用了remove方法移除Fragment,在返回来的时候报 Attempt to write to field 'int android.support.v4.app. ...

  9. [转]android.support.v4.app.Fragment和android.app.Fragment区别

      1.最低支持版本不同 android.app.Fragment 兼容的最低版本是android:minSdkVersion="11" 即3.0版 android.support ...

随机推荐

  1. iOS 11 Xcode 开发包SDK

    一不小心,手机又升级了,哎

  2. Zabbix server 3.2安装部署

    zabbix server 前提环境: CentOS 6 Lnmp php需要的包(bcmath,mbstring,sockets,gd,libxml,xmlwriter,xmlreader,ctyp ...

  3. I.MX6 linux tslib Corrupt calibration data

    I.MX6 linux tslib Corrupt calibration data 一.tslib出错 Corrupt calibration data 二.解决方法: ...... if [ -f ...

  4. [Python]定时任务框架 APScheduler

    1.使用APScheduler教程 参考博客地址

  5. 程序设计入门-C语言基础知识-翁恺-第三周:循环-详细笔记(三)

    目录 第三周:循环 3.1 循环 3.2 循环计算 3.3 课后习题 3.4 讨论题(不需要掌握) 第三周:循环 3.1 循环 while循环 语法: while(条件表达式){ //循环体语句 } ...

  6. 【老生常谈】Attr与Prop的区别

    “你为什么要做一个程序员?”,“因为我有一颗改变世界的心!”,“说人话”,“因为我没朋友...” -------------纯属娱乐 ================================= ...

  7. HihoCoder 1055 : 刷油漆 树形DP第一题(对象 点)

    刷油漆 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 上回说到,小Ho有着一棵灰常好玩的树玩具!这棵树玩具是由N个小球和N-1根木棍拼凑而成,这N个小球都被小Ho标上了 ...

  8. AngularX Http服务总结

    自己经常用的方式: 1.首先看httpModule Angular2的http访问经常采用两种方式: 共同点:导入相应的Module import {Http, RequestOptions, Res ...

  9. Cookie用法

    //写入 protected void Button1_Click(object sender, EventArgs e) { HttpCookie cookie=new HttpCookie(&qu ...

  10. WPF/UWP 绑定中的 UpdateSourceTrigger

    在开发 markdown-mail 时遇到了一些诡异的情况.代码是这么写的: <TextBox Text="{Binding Text, Mode=TwoWay}"/> ...