android - 绑定 Html 的用户数据绑定。fromHtml 字符串 android
问题描述
嗨,我是 mvvm 结构的新手,我在这里学习新东西。目前,我已将默认字符串与我的视图绑定,我有多种颜色的文本,因此我选择使用 HTML.fomHTml 螺母,我无法使用,任何人都可以帮助解决我的测试代码下方的此绑定问题....
资料>
<import type="android.text.Html"/>
<variable
name="loginviewmodel"
type="app.road2xtech.neighbourhood.view.viewmodel.LoginViewModel" />
</data>
<TextView
android:id="@+id/textViewAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="56dp"
android:fontFamily="@font/raleway_regular"
android:gravity="center"
android:text="@={Html.fromHtml(loginviewmodel.accountString)}"
android:textColor="@android:color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
它会给我以下错误
The expression 'android.text.Html.fromHtml(loginviewmodelAccountString)' cannot be inverted, so it cannot be used in a two-way binding
Details: There is no inverse for method fromHtml, you must add an @InverseMethod annotation to the method to indicate which method should be used when using it in two-way binding expressions
解决方案
推荐阅读
- python - 将网页表格直接捕获到数据框中
- python - 如何使用步长 +/-5 生成随机序列
- r - R:存储循环的结果
- python - 如何删除连接到外键 django 的项目?
- google-apps-script - 你如何覆盖数据而不是 appendRow?
- javascript - 如何在 CoinGecko 中访问 API 子组件
- css - Django:仅使用 rows 参数调整 Forms Textarea 的高度
- api - 如何在后台运行我的 Web 应用程序?
- javascript - 将带参数的函数传递给 cronjob
- kubernetes - 如何将 Gitlab 的容器注册表用于带有 ArgoCDs CI/CD 机制的 Helm Charts?