如何解决为 Material Design TextInputEditText 从布局 XML 调用 onTextChanged 处理程序
以下是用于布局 [credit material.io] 中的文本字段的示例代码:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/label">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
在代码中,您可以简单地附加一个侦听器:
editText.doAfterTextChanged {
...
}
有没有办法直接从 XML 调用文本更改处理程序?类似于 EditText 可以做什么?
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/edit_text"
android:text="blah blah"
android:onTextChanged="@{blah.onTextChanged}"/>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。