[英]Unable to parse XML - Kotlin
Caused by:
org.gradle.workers.internal.DefaultWorkerExecutor$WorkExecutionException: A
failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable
FAILURE: Build completed with 2 failures.
A failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable Failed to parse XML file '/home/shinto/Documents/PostMethodTrialChecking/HelpIntern/app/build/intermediates/packaged_res/debug/layout/fragment_signup.xml'
A failure occurred while executing com.android.build.gradle.internal.res.ParseLibraryResourcesTask$ParseResourcesRunnable Failed to parse XML file '/home/shinto/Documents/PostMethodTrialChecking/HelpIntern/app/build/intermediates/packaged_res/debug/layout/fragment_signup.xml'
fragment_signup.xml
<data>
<variable
name="users"
type="com.shinto.helpintern.MainViewModel" />
</data>
android:visibilities="@{users.}"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/progBar"
android:layout_width="match_parent"
android:layout_height="match_parent">
Your XML code is wrong.您的 XML 密码错误。 And as the error suggests, compiler expects a
<
, means an opening tag.正如错误所暗示的那样,编译器需要一个
<
,表示一个开始标记。 Why?为什么?
Because this line android:visibilities="@{users.}"
is misplaced and isn't in any tag.因为这一行
android:visibilities="@{users.}"
放错了位置,不在任何标签中。 Even if it was in its correct position, it wouldn't work, because there's nothing called visibilities
, it's visibility
.即使它是正确的 position,它也不起作用,因为没有什么叫做
visibilities
,它是visibility
。
I assume you want to toggle the visibility of the ContraintLayout
based on any (assuming boolean) value of the data.我假设您想根据数据的任何(假设为布尔值)值切换
ContraintLayout
的可见性。 To do that, change your code as:为此,请将您的代码更改为:
<data>
<import type="android.view.View"/>
<variable
name="users"
type="com.shinto.helpintern.MainViewModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/progBar"
android:visibility="@{users.yourValue? View.GONE : View.VISIBLE}"
android:layout_width="match_parent"
android:layout_height="match_parent">
This will toggle the layout's visibility based on the value of your model.这将根据您的 model 的值切换布局的可见性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.