当前位置:   article > 正文

Android include 使用注意事项E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example_fatal exception: main process: com.example.address

fatal exception: main process: com.example.addressbooksystem, pid: 7253

 

  1. E/AndroidRuntime: FATAL EXCEPTION: main
  2. Process: com.example.administrator.medx_media, PID: 4283
  3. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.administrator.medx_media/com.example.administrator.medx_media.MainActivity}: android.view.InflateException: Binary XML file line #16: You must specify a layout in the include tag: <include layout="@layout/layoutID" />
  4. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2793)


这是一个不熟悉include空间的翻车现场。

  1. <include
  2. android:layout_width="match_parent"
  3. android:layout_height="match_parent"
  4. android:layout="@layout/layout_head"
  5. android:layout_weight="11"/>

 

 

每次编译时都会报错,看了很多文章,才找到正确的答案,那就是

一个控件的基础属性的问题。长记性了。

正确的格式演示是:

  1. <include
  2. android:id="@+id/title"
  3. layout="@layout/include_title"
  4. app:layout_constraintEnd_toEndOf="parent"
  5. app:layout_constraintStart_toStartOf="parent"
  6. app:layout_constraintTop_toTopOf="parent"></include>

把android:去掉即可  (   layout="@layout/include_title")

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/382608
推荐阅读
相关标签
  

闽ICP备14008679号