Android“无法解析符号'@id/myLabel”

use*_*356 1 java xml android android-layout

我收到一个错误,说“ Cannot resolve symbol '@id/myLabel'”。以下元素也有同样的错误:

"Cannot resolve symbol '@id/numberStudents'"
"Cannot resolve symbol '@id/accept'"
Run Code Online (Sandbox Code Playgroud)

请帮我解决这个问题。我的 xml 示例粘贴在下面。

谢谢,阿比拉什·卡达拉。

<?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="fill_parent">
    <TextView  
        android:id="@+id/myLabel"
        android:text="Name of student:"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
    />
    <EditText
        android:id="@+id/numberStudents"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/myLabel"
    />
    <Button
        android:id="@+id/accept"
        android:text="Accept"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/numberStudents"
        android:layout_alignParentRight="true"
        android:layout_marginLeft="10px"
    />
    <Button
        android:id="@+id/cancel"
        android:text="Cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/accept"
        android:layout_alignTop="@id/accept"
    />

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

小智 7

尝试使缓存无效并重新启动,对我有用:)


sye*_*gir 5

Rebuild project 对我有用。


Bip*_*rti 0

这是因为你像这样声明 id@+id/accept并使用像这样的另一个地方@id/accept