【发布时间】:2021-05-05 06:15:03
【问题描述】:
以下是我的主要布局,其中包含了另一个布局
<layout 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">
<data>
<variable
name="userName"
type="String" />
<variable
name="hasEnded"
type="Boolean" />
<variable
name="showLoader"
type="Boolean" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/parent_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/base_chat_background">
<com.commonui.AppBar
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@{userName}"
app:addWindowInsetPaddingTop="@{true}"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="0dp"
android:layout_height="0dp"
android:clipToPadding="false"
android:paddingTop="16dp"
android:paddingBottom="70dp"
app:addWindowInsetPaddingBottom="@{true}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/app_bar" />
<include
android:id="@+id/feedbackLayout"
visibleIf="@{hasEnded}"
layout="@layout/chat_feedback"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<ProgressBar
android:id="@+id/loader"
visibleIf="@{showLoader}"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:indeterminate="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/app_bar" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
我有一个扩展函数,我用它来处理 XML 中视图的可见性
@BindingAdapter("visibleIf")
fun setVisibleIf(view: View, visible: Boolean) {
view.visibility = if(visible) View.VISIBLE else View.GONE
}
当我将 visibleIf="@{hasEnded}" 添加到包含的布局并构建项目时,我收到错误
error: cannot find symbol
import com.chat.databinding.FragmentPeerchatBindingImpl;
symbol: class FragmentChatBindingImpl
location: package com.chat.databinding
可能是什么原因造成的?
【问题讨论】:
-
检查this
标签: android kotlin fragment android-databinding