gpt4 book ai didi

Android Studio 在 layout.xml 中显示错误

转载 作者:行者123 更新时间:2023-11-29 01:05:51 25 4
gpt4 key购买 nike

我正在使用数据绑定(bind)库,我在 Android Studio 3.0 中遇到以下问题:

somelayout.xml:

<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<data>
<variable
name="meeting"
type="some.package.MeetingStatusResponse"/>
</data>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{meeting.title}"
tools:text="Title"
/>


...


</LinearLayout>
</layout>

在这个地方:android:text="@{meeting.title}" Android Studio 3.0 下划线 @ 符号并通知错误:

Error:(29, 27) <expr> or <lambda expression> expected, got '@'

如果有任何相关性,模型类是用 Kotlin 编写的。代码完成也不适用于绑定(bind)类。 可以使用 gradle 命令和 Android Studio 运行应用程序按钮成功构建应用程序。所以这只是编辑器问题

我在 Mac 上发现了这个问题。在 Windows 上它工作正常。我没有更多的计算机来检查它是否与平台相关的问题。

最佳答案

也许你忘了在 gradle 中添加 compileOptions

    `sourceCompatibility JavaVersion.VERSION_1_7`
`targetCompatibility JavaVersion.VERSION_1_7`

关于Android Studio 在 layout.xml 中显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47345773/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com