【发布时间】:2021-04-12 20:42:34
【问题描述】:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:androids="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="titleViewModel"
type="com.example.screen.title.TitleViewModel" />
</data>
<LinearLayout
androids:id="@+id/title_layout"
androids:layout_width="match_parent"
androids:layout_height="match_parent"
androids:gravity="center"
androids:orientation="vertical"
tools:context=".screen.title.TitleFragment">
...more
我有一个错误:第一次尝试在 Android 应用程序开发中进行数据绑定时,“
我检查了其他相关线程,他们说这是关于 XML 命名空间的,但这里似乎不是问题,不是吗?如果不是,如何解决?
【问题讨论】:
-
用
xmlns:android="http://schemas.android.com/apk/res/android"替换xmlns:androids="http://schemas.android.com/apk/res/android" -
我是否必须将每个 androids:XXX 更改为 android:XXX?
-
是的,应该是
android而不是androids。 -
谢谢!它有效,我认为它就像变量一样。但是,我不明白为什么
androids在没有<layout>和<data>标签的情况下工作?
标签: android xml data-binding android-linearlayout