我在XML文件中遇到了一个ID错误,尽管它是唯一的

发布于 2025-02-11 02:23:40 字数 3077 浏览 0 评论 0原文

我的XML文件工作正常,直到我创建了一个新的textView,并决定给它一个ID,即txtvw6,尽管它是唯一的,但它给了我一个错误。当我按 Alter+Enter 时,它会给我创建资源ID值。 我能知道此ID怎么了吗?

编辑:我刚刚关闭了Android Studio并再次重新开放,错误消失了!

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/txtVw1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="25dp"
                android:text="Hello world!"/>
    
            <TextView
                android:id="@+id/txtVw2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:textColor="@color/white"
                android:gravity="center"
                android:background="@color/purple_200"
                android:text="15\nJun"/>
    
            <TextView
                android:id="@+id/txtVw3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:gravity="center"
                android:text="Text number3"/>
    
            <TextView
                android:id="@+id/txtVw4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:gravity="center"
                android:text="TextView number4"/>
    
            <TextView
                android:id="@+id/txtVw5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:drawableLeft="@drawable/android0"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:text="Image TextView"/>
    
            <TextView
                android:id="@+id/txtVw6" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:text="TextView 6"/>
    
        </LinearLayout>
    </ScrollView>

My xml file was working fine until I created a new TextView and decided to give it an id which is txtVw6 that gave me an error although it is unique. when I press Alter+Enter it gives me create resource id value .
Can I Know what is wrong with this ID?

Edit : I've just closed android studio and reopen it again, the error is gone!

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="center"
        android:orientation="vertical"
        tools:context=".MainActivity">
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:gravity="center"
            android:orientation="vertical">
    
            <TextView
                android:id="@+id/txtVw1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="25dp"
                android:text="Hello world!"/>
    
            <TextView
                android:id="@+id/txtVw2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:textColor="@color/white"
                android:gravity="center"
                android:background="@color/purple_200"
                android:text="15\nJun"/>
    
            <TextView
                android:id="@+id/txtVw3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:gravity="center"
                android:text="Text number3"/>
    
            <TextView
                android:id="@+id/txtVw4"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:gravity="center"
                android:text="TextView number4"/>
    
            <TextView
                android:id="@+id/txtVw5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:drawableLeft="@drawable/android0"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:text="Image TextView"/>
    
            <TextView
                android:id="@+id/txtVw6" 
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10pt"
                android:textSize="25dp"
                android:text="TextView 6"/>
    
        </LinearLayout>
    </ScrollView>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文