把app的targetSdkVersion和compileSdkVersion升级到23以后,在进入某些页面的时候,出现了崩溃:

 Caused by: java.lang.IllegalArgumentException: Binary XML file line #49: Must specify unique android:id, android:tag, or have a parent with an id for com.xxx.XXXFragment

对应的布局文件如下:

 <fragment
        android:layout_width="match_parent"android:layout_height="match_parent"android:name="com.haodf.prehospital.doctorhome.DoctorExperienceFragment"/>

就是一个Fragment的标签,那问题出在哪里呢?
官网中对于FragmentActivity的描述中,有这么一句:

When using the tag, this implementation can not use the parent view’s ID as the new fragment’s ID. You must explicitly specify an ID (or tag) in the .

意思就是呢,你要是用标签的话呢,你得显示的给他指定一个id或是tag。FragmentManager的源码也验证了这一点:

 @Overridepublic View onCreateView(View parent, String name, Context context, AttributeSet attrs) {if (!"fragment".equals(name)) {return null;}String fname = attrs.getAttributeValue(null, "class");TypedArray a =  context.obtainStyledAttributes(attrs, FragmentTag.Fragment);if (fname == null) {fname = a.getString(FragmentTag.Fragment_name);}int id = a.getResourceId(FragmentTag.Fragment_id, View.NO_ID);String tag = a.getString(FragmentTag.Fragment_tag);a.recycle();if (!Fragment.isSupportFragmentClass(mHost.getContext(), fname)) {// Invalid support lib fragment; let the device's framework handle it.// This will allow android.app.Fragments to do the right thing.return null;}int containerId = parent != null ? parent.getId() : 0;if (containerId == View.NO_ID && id == View.NO_ID && tag == null) {throw new IllegalArgumentException(attrs.getPositionDescription()+ ": Must specify unique android:id, android:tag, or have a parent with an id for " + fname);}......return fragment.mView;}

Must specify unique android:id, android:tag, or have a parent with an id for XXX相关推荐

  1. android获取子线程id,Android 开发 知晓各种id信息 获取线程ID、activityID、内核ID

    /*** Returns the identifier of this process's user. * 返回此进程的用户的标识符.*/Log.e(TAG,"Process.myUid() ...

  2. Android 不得不知Tag的妙用

    setTag () 是 Android 的 View 类中很有用的一个方法,可以用它来给控件附加一些信息,在很多场合下都得到妙用.我们可以看到 setTat() 有两个方法重载,setTag(Obje ...

  3. android子view获取父布局,Android获取布局父ID(Android get layout parent id)

    Android获取布局父ID(Android get layout parent id) 我想知道View和ViewParent有什么区别? 我想获取ImageView父级的Id,但我不能这样做: m ...

  4. Android获取NFC标签和NFC十进制16进制ID

    要获取NFC标签,首先需要添加NFC权限 <uses-feature android:name="android.hardware.nfc" android:required ...

  5. 格式android id,android 获取APP的唯一标识applicationId的实例

    使用getIdentifier()方法可以方便的获各应用包下的指定资源ID. 方式一 int indentify = getResources().getIdentifier("com.te ...

  6. Android报“android.content.res.Resources$NotFoundException: String resource ID #0x2”错误

    Android报"android.content.res.Resources$NotFoundException: String resource ID #0x2"错误 当调用se ...

  7. android 指定资源id,Android 通过名称获取资源ID

    当我们获取网络数据的时候,解析之后往往都是一个字符串,而不是资源id,所有我们没有办法直接使用,只能通过名称来获取到资源id, package com.example.administrator.de ...

  8. android:id = @+id 用法,@+id/android:list和@android:id/list的写法

    Android中的列表,当然也可以用ListView来完成所需要的功能,用法是一样的. 废话不说,来关键的. LiveActivity本身继承了关于List操作的众多接口,我们可以方便的重写这些操作中 ...

  9. android:id=@android:id/tabhost 、android:id=@+id/llRoot 、android:id=@id/llRoot 之间的区别...

    由于快要放暑假了,所以最近这俩周把Android方面的知识复习一下,准备找个实习工作. 顺便把自己的总结更大家分享一下,共同进步,谢谢.... 一. android:id="@android ...

  10. android:id=@android:id/list,Logcat错误 - 内容必须有一个ListView的id属性是'android.R.id.list'...

    我的列表视图显示这样的错误我在我的问题中提到的事件,尽管我在mainactivity中提到扩展listactivity也和我的布局我把尽可能的ListViewLogcat错误 - 内容必须有一个Lis ...

最新文章

  1. iOS 改变UILabel部分颜色
  2. IntelliJ如何设置自动导包
  3. 将可见的电子签名添加到PDF
  4. Java RandomAccessFile writeBytes()方法与示例
  5. 二叉树层次遍历python_根据二叉树层序遍历顺序(数组),将其转换为二叉树(Python)...
  6. c语言发展过程,C语言发展史
  7. web前端基础(06css)
  8. 开源 RPC 框架有哪些
  9. postman传递数组参数
  10. Effective Modern C++ 第一章 C++11/14/17中的类型推断
  11. 博文视点大讲堂第30期——职场新人胜出的关键点
  12. 22年国内最牛的Java面试八股文合集(全彩版),不接受反驳
  13. 【小白向】如何更换文件夹图标
  14. 史上最怪异的几大数据中心事故
  15. matlab 保存图片大小尺寸_改变figure大小存储图片(matlab)
  16. (三)SGE 部署 SGE
  17. linux服务器 ip地址,查看linux服务器的IP地址
  18. 基于物联网的智能家居系统设计QY-LYZN
  19. 如果作为公司员工,有什么困难、意见建议
  20. 恒温matlab的仿真程序,基于Matlab恒温箱温度控制系统设计与仿真

热门文章

  1. CSS font-family 各名称一览表
  2. 电子测量技术——基于Python的测量数据误差处理程序
  3. java持久化框架对比_四种流行的持久化框架比较
  4. 基于Echarts的图表绘制
  5. oracle中文转全拼音,oracle汉字转拼音
  6. BPSK调制gardner算法的MATLAB实现
  7. c#使用word、excel、pdf ——转
  8. 【批处理bat】注释一段文本/字符串
  9. 【ODBC】ODBC连接数据库详细说明
  10. html中css层叠样式表(行内样式,内嵌式,外部式)