android - Android TextView:与另一个具有相同 ID 的标签冲突
问题描述
我对 Android XML 文件有疑问,需要您的帮助。我有以下代码:
<TextView
android:id="@+id/textViewA"
android:layout_width="95dp"
android:layout_height="35dp"
android:text="A"
android:textColor="#000000"
android:textSize="22dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.012"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.671" />
<TextView
android:id="@+id/textViewS"
android:layout_width="95dp"
android:layout_height="35dp"
android:text="S"
android:textColor="#000000"
android:textSize="22dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.012"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.584" />
所以基本上我有两个TextView。当我编译时,我收到错误消息:
'<TextView id='@+id/textView'> conflicts with another tag that has the same ID'
当我单击错误的相应行时,会显示这两个 TextView。我不太明白这一点,因为他们没有相同的 ID。他们曾经有相同的ID,但我改变了它,仍然出现问题。也许这与我刚刚启用的 ViewBinding 有关?我会很感激每一条评论。
更新:我意识到实际上与 ViewBinding 有关,因为我还可以看到以下信息:
Found data binding error(s):
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\T.D\\AndroidStudioProjects\\BarApp\\BarApp_Projekt\\app\\src\\main\\res\\layout\\activity_cocktail_ytest.xml","pos":[{"line0":48,"col0":4,"line1":61,"col1":52}]}
[databinding] {"msg":"\u003cTextView id\u003d\u0027@+id/textView\u0027\u003e conflicts with another tag that has the same ID","file":"C:\\Users\\T.D\\AndroidStudioProjects\\BarApp\\BarApp_Projekt\\app\\src\\main\\res\\layout\\activity_cocktail_ytest.xml","pos":[{"line0":121,"col0":4,"line1":134,"col1":52}]}
但我仍然不知道错误的原因。我的意思是他们绝对没有相同的ID。
解决方案
使缓存无效并重新启动 android studio 将对您有所帮助。
推荐阅读
- java - mvn clean package spring-boot:repackage -f pom.xml 失败,找不到包
- c - Pset5 Speller:我的小字典出现分段错误
- sql - 如何对列 jsonb 类型使用通配符
- python - 无法访问 docker 容器 Socket 挂起错误
- javascript - removeEventListener 无法按预期工作
- ruby-on-rails - 强制重新编译单个 .js.erb 文件
- google-cloud-platform - 对于 bigtable 实例,gcloud cli 显示的可授予角色少于 gcp 控制台
- xcode - xcodebuild 无法构建项目
- cordova - Cordova 相机插件 DATA_URL 不返回文件名或扩展名
- javascript - 我正在尝试使用 react-redux 存储我的数据,但它没有。我该如何解决这个问题?