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

报告相同问题?

悬赏问题

  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)