我正在创建一个 Android 应用程序,我想使用一个功能,在该功能中,我们输入到 editText 字段中的文本可以在运行时仅在该特定的 editText 字段中转换为大写。
我尝试过使用这段代码
editText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
this.text.toString().uppercase()
}
})
Run Code Online (Sandbox Code Playgroud)
但是通过android中的Inverse Binding Adapter的概念就可以轻松完成。我尝试参考 https://developer.android.com/reference/android/databinding/InverseBindingAdapter来实现它
它在我的项目中对我不起作用。你能一步步解释一下吗?