0

So the question is pretty simple i want to remove the text that appears in the spinner because I don't need it and i have a image there.

I found this answer but I can't make it work in xamarin (c#), anyone know a way how to make it on c# ?

my layout code :

                <Spinner
                    android:id="@+id/pointer"
                    android:gravity="center"
                    android:background="@drawable/pointer"
                    android:layout_centerHorizontal="true"
                    android:layout_marginTop="13.5dp"
                    android:layout_width="23.33dp"
                    android:layout_height="23.33dp" 
                    android:prompt="@string/city_prompt"
                    />

and my main code :

protected override void OnCreate (Bundle bundle)
            {
SetContentView (Resource.Layout.Main);

    Spinner spinner = FindViewById<Spinner> (Resource.Id.pointer);

        spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs> (spinner_ItemSelected);
        var adapter = ArrayAdapter.CreateFromResource (
            this, Resource.Array.citys_array, Android.Resource.Layout.SimpleSpinnerItem);

        adapter.SetDropDownViewResource (Android.Resource.Layout.SimpleSpinnerDropDownItem);
        spinner.Adapter = adapter;

    }

    private void spinner_ItemSelected (object sender, AdapterView.ItemSelectedEventArgs e)
    {
        Spinner spinner = (Spinner)sender;

        string toast = string.Format ("{0}", spinner.GetItemAtPosition (e.Position));
        Toast.MakeText (this, toast, ToastLength.Long).Show ();
    }

Any suggestions ? Thank you for your time, Daniel.

Community
  • 1
  • 1

0 Answers0