仅限Android 4.0上的MvxSpinner Blank

1 android xamarin.android mvvmcross xamarin

我有一个自定义绑定MvxSpinner,它与我的Android和iOS应用程序之间共享的ViewModel一起使用.在Android API Level 15(4.0.3)及更高版本上,一切看起来都很棒,但在Android API Level 14(4.0)上,微调器会为每个ListItem元素显示空白文本.ListItems在那里,但Text只是空白.当我在Android 4.0上进行选择时,将正确的值传递回所选项目的ViewModel,我的应用程序也会相应更新.

Android 4.0上有MxvSpinner的已知错误吗?

这是我的MvxSpinner的XML:

<MvxSpinner
        style="@style/spinner_input"
        local:MvxItemTemplate="@layout/item_spinner"
        local:MvxDropDownItemTemplate="@layout/item_spinnerdropdown"
        local:MvxBind="ItemsSource ProductCategoryOptions; SelectedItem SelectedProductCategory" />
Run Code Online (Sandbox Code Playgroud)

这是我的模板:

item_spinner

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:textAppearance="?android:attr/textAppearanceMedium"
    android:textColor="@color/black"
    android:text="Test"
    local:MvxBind="Text Caption" />
Run Code Online (Sandbox Code Playgroud)

Item_SpinnerDropDown

<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    style="?android:attr/spinnerDropDownItemStyle"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    local:MvxBind="Text Caption" />
Run Code Online (Sandbox Code Playgroud)

小智 5

因为这个问题还没有标记为已回答,我不知道答案是否已经找到,我发布我的解决方案以供将来的读者参考.

将以下代码放在名为的文件中LinkerPleaseInclude.cs:

public void Include(CheckedTextView checkedText)
{
    checkedText.TextChanged += (sender, args) => checkedText.Text = string.Empty + checkedText.Text;
    checkedText.Hint = string.Empty + checkedText.Hint;
}
Run Code Online (Sandbox Code Playgroud)

这是链接器包含CheckTextView绑定所必需的.这适用于Android API 16 v4.1.x,在VS2013中启用了"仅限Sdk Assemblies"链接.