MvxSpinner item should be blank until not select from dropdown list

223 Views Asked by At

I'm using MvxSpinner and just want to show drop down selected value over spinner.Currently its showing first item from dropdown list but i want to show blank as i didn't choose any value from dropdown.

Spinner

<MvvmCross.Binding.Droid.Views.MvxSpinner
        android:id="@+id/mySpinner"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        local:MvxDropDownItemTemplate="@layout/myspinner_item"
        local:MvxItemTemplate="@layout/myspinner_item"
        android:layout_marginLeft="0dp"
        android:dropDownWidth="257dp"
        android:dropDownSelector="@drawable/list_item_selector"
        android:layout_centerInParent="true"
        android:spinnerMode="dropdown"
        local:MvxBind="ItemsSource MyItems; HandleItemSelected SelectCommand" />

myspinner_item

<?xml version="1.0" encoding="utf-8"?>
<MvvmCross.Binding.Droid.Views.MvxLinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/list_item_selector"
    android:orientation="horizontal">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="32dp"
        android:textSize="15sp"
        android:textColor="#de000000"
        android:lineSpacingExtra="5sp"
        android:singleLine="true"
        android:text=""
        android:layout_marginTop="6dp"
        android:layout_marginBottom="6dp"
        android:layout_marginLeft="24dp"
        local:MvxBind="Text Description; Typeface StringToFont('Effra_Rg')" />
</MvvmCross.Binding.Droid.Views.MvxLinearLayout>
1

There are 1 best solutions below

1
Swisscheese On

It's showing the first item because it's bound to the item list. Might be considered bad practice by some, but if your goal is for it to stay blank until chosen, have you tried adding a new item to the front of your list with a blank description?