gpt4 book ai didi

c# - 无法使用 MvxBind 设置 BackgroundColor

转载 作者:行者123 更新时间:2023-11-30 00:14:50 29 4
gpt4 key购买 nike

我正在尝试更改 RecyclerView 的项目颜色。下面的代码仅显示了项目布局的根布局 RelativeLayout。

我有以下代码:

(项目)布局:

<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="@+id/item_listitem"
android:layout_width="match_parent"
android:layout_height="48dp"
android:orientation="horizontal"
android:paddingTop="2dp"
android:paddingBottom="2dp"
android:paddingStart="@dimen/margin_left_shoppinglistitems"
android:paddingEnd="@dimen/margin_medium"
local:MvxBind="BackgroundColor NativeColor(Background)">

...

</RelativeLayout>

View 模型:

public class ListItem : TableData, IListItem
{
...
public MvxColor Background { get { return new MvxColor(255,189,69,128); } }
...
}

我已将 MvvmCross.Plugin.Color 添加到 Droid 和 Core 项目中。我不知道为什么这不起作用?我可以看到正在访问 Background 属性,但颜色未设置为设置的测试值(将来我希望颜色基于另一个 bool 属性)。有什么想法吗?

最佳答案

检查您是否安装了颜色插件并对其进行了初始化。我以这种方式使用绑定(bind):local:MvxBind="BackgroundColor 背景, Converter=NativeColor"

关于c# - 无法使用 MvxBind 设置 BackgroundColor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47462300/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com