2014-01-17 28 views
1

我有一個自定義綁定MvxSpinner,它與我的Android和iOS應用程序共享的ViewModel非常適合。在Android API Level 15(4.0.3)以上,一切看起來都很棒,但在Android API Level 14(4.0)上,微調框顯示每個ListItem元素的空白文本。 ListItems在那裏,但文本只是空白。當我在Android 4.0上進行選擇時,正確的值將傳遞迴所選項目的ViewModel,並且我的應用程序會相應更新。Android 4.0上的MvxSpinner Blank僅限

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" /> 

這裏是我的模板:

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" /> 

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" /> 

回答

0

MvvmCross和Android 4.0上的自定義綁定有沒有已知的錯誤?

沒有,我知道的 - 但無可否認,我不上4.0測試了 - 我現在的仿真器設置包括2.3.6,4.0.3,4.1和4.4.2

(我也是不知道你爲什麼稱之爲「定製綁定」 - 我假定這只是使用標準MvxBinding而不是任何添加/客戶化)

有一對夫婦的bug /問題MVX目前正在跟蹤各地MvxSpinner/MvxListView激活和通貨膨脹Android 4+和4.4的變化 - 但都不在'隱形'區域 - 請參閱:

恐怕這不是一個回答您的問題/問題。在您的Android v4.0配置中嘗試使用不同的顏色和佈局可能是值得的,也許可以使用hierarchyviewer來檢查顯示的UI。在這裏看到的問題有很多關於Spinner在4.0中的可見性的評論(但我看不到任何直接有用的東西) - https://stackoverflow.com/search?q=spinner+4.0

+0

感謝您的參考。我在各種設備/模擬器中獲得不一致的結果。如果我使用Xamarin進行構建並在模擬器中進行調試,則文本將顯示在下拉菜單中,但如果通過TestFlight構建和部署,則不會顯示文本。如果它可以被調試,那麼它就不會那麼糟糕,並且對於只有一個版本的Android使用特定的部署方案而言並不是一個問題。 如果我發現它與控件有關的任何問題,我會在這裏回覆。 – jdubbish

0

這似乎是本地的問題:MvxBind =「Text Caption」property not在CheckedTextView對象上正確更新。

我改變了我的Item_SpinnerDropDown.xml以下(「CheckedTextView」到「的TextView」),一切的現在的工作:

<?xml version="1.0" encoding="utf-8"?> 
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:local="http://schemas.android.com/apk/res-auto/WIRECOWEBMOB.Droid" 
android:singleLine="true" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:textAppearance="?android:attr/textAppearanceMedium" 
android:textColor="@color/black" 
local:MvxBind="Text Caption" /> 

這不是下拉的首選功能(缺乏經過可見度),但它現在適用於所有版本。

另一個說明:我發現這是發佈版本的問題,而不是一個特定的Android版本。我正在使用Debug模式下的所有SDK版本,並且它們在我的模擬器中運行良好,但是一旦我切換到Release,顯示的空白下拉列表項就會出現。

5

因爲這個問題還沒有被標記爲回答,我不知道答案是否已經被發現,我發佈我的解決方案,以供將來的讀者參考。

,將文件放在下面的代碼名爲LinkerPleaseInclude.cs

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

這是必要的鏈接器包括CheckTextView綁定。這適用於Android API 16 v4.1.x,並且在VS2013中啓用鏈接「僅限Sdk Assemblies」。

+0

謝謝 - 我有完全相同的問題 - 在調試時看起來沒問題,但發佈時文本空白。您的解決方案奏效 –

+0

我有同樣的問題。你的解決方案非常好,謝謝。 – RyanWang

0

不確定是否相關,但它幫助了我。

我,而不是綁定到我的MvxSpinner整數列表,當我試圖用

local:MvxBind="Text Caption" 

在item_spinner.axml和item_spinnerdropdown.axml

結果是一個空白我的價值觀。我認爲這是因爲int沒有Caption屬性,所以我試圖改變綁定,所以它綁定到對象本身,而不是它的屬性。就這麼幹或者這樣:

local:MvxBind="Text ." 

左右:

local:MvxBind="Text" 

有差異的相關話題: Are "{Binding Path=.}" and "{Binding}" really equal

那麼,什麼可以幫助正在改變你的模板代碼:

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 ." /> 

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 ." />