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条)

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大