1

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>
James Z
  • 12,209
  • 10
  • 24
  • 44
Chanki
  • 165
  • 13
  • This is just the way the Android Spinner works. You can do what Swisscheese suggested, or make your own adapter but it's a lot of work for very little gain. – Trevor Balcom May 10 '18 at 20:52

1 Answers1

3

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?

Swisscheese
  • 571
  • 1
  • 5
  • 21
  • I tried earlier and its work fine but as you know it will show blank space once you open dropdown which seems to be cosmetic issue that's why i was looking for workaround :). – Chanki May 11 '18 at 07:15