我在XML文件中遇到了一个ID错误,尽管它是唯一的
我的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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论