Daniel_cf 2013-01-31 06:24 采纳率: 100%
浏览 4801
已采纳

当用<include layout=“”>的时候报错:“No resource found”

在我的project中,我已经创建了一个全局的头layoutglobal_header.xml,而且我通过用<include layout="@layout/global_header.xml">把它用在了我所有的布局XML文件中。

之前我用过这个方法,现在我在这个project中用这个方法。我的问题的是我有一个layout用的下边的content:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#FFFFFFFF" >

    <include layout="@layout/global_header" />

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@global/header">

        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >
        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

global_header.xml的contents:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+global/header"
    android:layout_width="fill_parent"
    android:layout_height="60sp"
    android:layout_alignParentTop="true"
    android:background="#FFDDDDDD" >

    <ImageView
        android:id="@+id/global_header_logo"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5sp"
        android:layout_marginTop="5sp"
        android:adjustViewBounds="true"
        android:src="@drawable/header" />

    <View
        android:layout_width="fill_parent"
        android:layout_height="1sp"
        android:layout_alignParentBottom="true"
        android:background="#FF000000" />

</RelativeLayout>

我在 android:layout_below="@global/header"得到了一个错误:

error: Error: No resource found that matches the given name (at 'layout_below' with value '@global/header').

我之前在project的其他layout中用过,没有问题,但是不知道什么原因,这个layout文件不能像其他的layout一样从头文件处加载ID。
有这个问题的话project就不能build,尽管我知道一旦在设备中运行的话这不是个问题,还有人遇到过这个问题么?有什么解决办法么?

  • 写回答

2条回答 默认 最新

  • Billy_崔海斌 2013-01-31 08:44
    关注
    <include layout="@layout/global_header" android:id="@+global/header"/>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建