1

I have a custom bound MvxSpinner that works great with a ViewModel that's shared between my Android and iOS apps. On Android API Level 15 (4.0.3) and above everything looks great, but on Android API Level 14 (4.0) the spinner displays blank text for each ListItem element. The ListItems are there, but the Text is just blank. When I make a selection on Android 4.0 the proper value is passed back to the ViewModel for the selected item, and my app updates accordingly.

Are there any known bugs with MxvSpinner on Android 4.0?

Here's the XML for my MvxSpinner:

<MvxSpinner
        style="@style/spinner_input"
        local:MvxItemTemplate="@layout/item_spinner"
        local:MvxDropDownItemTemplate="@layout/item_spinnerdropdown"
        local:MvxBind="ItemsSource ProductCategoryOptions; SelectedItem SelectedProductCategory" />

And here are my templates:

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" />
jdubbish
  • 11
  • 2

4 Answers4

5

Because this question isn't marked as answered yet and I don't know if the answer was found already, I post my solution for reference to future readers.

Place the following code in the file called LinkerPleaseInclude.cs:

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

This is necessary for the linker to include the CheckTextView bindings. This works for Android API 16 v4.1.x with linking 'Sdk Assemblies Only' enabled in VS2013.

Remco Koedoot
  • 239
  • 4
  • 13
0

Are there any known bugs with MvvmCross and custom binding on Android 4.0?

None that I know of - but admittedly I don't test much on 4.0 - my current emulator set includes 2.3.6, 4.0.3, 4.1 and 4.4.2

(I'm also not sure why you call this "custom binding" - I'm assuming this is just using standard MvxBinding and not any additions/customisations)

There are a couple bugs/issues Mvx is currently tracking around MvxSpinner/MvxListView activation and inflation changes in Android 4+ and 4.4 - but neither of these are in the 'invisible' area - see:

I'm afraid this isn't an answer to your question/problem. It might be worth trying to use different colors and layouts within your Android v4.0 configuration, and perhaps using the hierarchyviewer to inspect the displayed UI. Looking through questions here there are quite a few comments about spinner visibility in 4.0 (but I couldn't see anything immediately helpful) - https://stackoverflow.com/search?q=spinner+4.0

Community
  • 1
  • 1
Stuart
  • 66,722
  • 7
  • 114
  • 165
  • Thanks for the references. I'm getting inconsistent results across devices/emulators. If I build with Xamarin and debug in an emulator the text appears in the dropdown's popup, but if I build and deploy via TestFlight the text doesn't appear. Wouldn't be so bad if it could be debugged and wasn't a problem with just one version of Android using specific deployment scenarios. If I find it's any sort of issue related to the controls I'll post back here. – jdubbish Jan 20 '14 at 21:25
0

This appears to be an issue with the local:MvxBind="Text Caption" property not updating properly on the CheckedTextView object.

I changed my Item_SpinnerDropDown.xml to the following ("CheckedTextView" to "TextView") and everything's working now:

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

This isn't the preferred functionality of the drop-down (lacking the Checked visibility), but it works across all builds now.

Another note: I found this was an issue with Release builds and not a specific Android version. I was working with all of the SDK versions in Debug mode and they worked fine in my emulators, but once I switched to Release the blank drop-down items showed up.

jdubbish
  • 11
  • 2
0

not sure if relevant yet, but it helped me.

I was binding to a list of integers in my MvxSpinner and when I tried to use

local:MvxBind="Text Caption"

in item_spinner.axml and item_spinnerdropdown.axml

The result was a blank space instead of my values. I supposed that it happens because int has no Caption property, so I tried to change the binding so it binds to the object itself, not to it's property. And it is done either so:

local:MvxBind="Text ." 

or so:

local:MvxBind="Text"

There's a topic about the difference: Are "{Binding Path=.}" and "{Binding}" really equal

So, what might help is changing your templates code to:

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 ." />
Community
  • 1
  • 1