【发布时间】:2020-04-19 03:36:02
【问题描述】:
在我的片段 xml 中实现数据绑定时,我在 EditText 中找不到属性 android:onTextChanged。我已经搜索了答案,this one 说它是开箱即用的。
我已经设置了
data-binding {
enable = true
}
在我的 build.gradle 中,我当前的 build gradle 是 3.5.3。
这是我的 xml 的一部分:
<layout>
<data>
<variable
name="vm"
type=".ViewModel" />
</data>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".screens.hangouts.create_hangout_new.Step1FragmentNew">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_category"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_hangout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/rv_category" />
<EditText
android:id="@+id/et_hangout_name"
android:background="@drawable/bkg_stroke_red"
android:layout_width="match_parent"
android:layout_height="30dp"
app:layout_constraintTop_toBottomOf="@id/tv_hangout_name" />
...
【问题讨论】:
-
你用的是kotlin还是java?
-
@haresh 我在我的项目中同时使用 java 和 kotlin。但主要是java。这是我找不到
onTextChanged属性的原因吗? -
兄弟你找到解决办法了吗??我也来自那个问题..
标签: android xml data-binding android-jetpack