RelativeLayout"无法解析资源......"Android

kie*_*ra5 19 android android-relativelayout

使用下面的代码时,我收到错误"无法解析资源@id/item1"为什么会这样?在我使用之前添加了id/item1,所以我不确定为什么会这样.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/item1"
        android:layout_width="50dip"
        android:layout_height="50dip"
        android:src="@drawable/noimage" />
    <TextView         
        android:id="@+id/item2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Title"
        android:padding="3dip" 
        android:textSize="20dip"
        android:layout_toRightOf="@id/item1"/>
    <TextView         
        android:id="@+id/item3"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Content"
        android:padding="3dip" 
        android:textSize="20dip"
        android:layout_below="@id/item1"/>

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

ina*_*ruk 19

我的代码没有这个错误.

确保您没有其他资源(布局,值,drawable等)的错误.然后清理/刷新/构建项目

  • 当有疑问时......重启日食.大概有一半我的机器人相关问题的答案-_- (11认同)
  • 我有同样的错误,并能够通过重新启动eclipse来解决它(清理没有帮助).虽然对我来说,图形相对布局编辑器在我拖动周围时崩溃了. (7认同)
  • 对于那些使用Android Studio和清洁没有帮助的人,重启也为我解决了问题. (3认同)

Sco*_*ggs 12

正如何塞所说,有时Android Studio会变得疯狂.但重启并不总是足够的.

使您的缓存无效并重新启动.

文件 - >使高速缓存/重新启动无效... - >无效并重新启动

菜单选择 在此输入图像描述

等到AS完全重新启动并重建.希望它在逻辑上表现得很好.