Im looking for a spinnerexample that include key/value like DisplayMember/ValueMember like Winforms. im Usign Xmarin.Android in Visual Studio 2017/2015, i being use this to populate, but it only contains MembersValue
<string-array>
<ítem>ITEM 1</ítem>
</string-array>
and i looking for some like:
<string-array>
<ítem value=1>ITEM 1</ítem>
</string-array>
where i can get the tag valuein the method click from a buttoncontrol like this:
private void btnButton(Object sender,EventArgs e)
{
string strValue=spinner.SelectedItem.ToString();
}
Actual Result : ITEM 1
Expected Result: 1
I was trying with a dictionary as show below:
var dict = new Dictionary<int, string>();
dict.Add(1, "Tarjeta1");
dict.Add(2, "tarjeta2");
and then Add as resource in the spinner:
spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(Spinner1_ItemSelected);
ArrayAdapter adapter = new ArrayAdapter(this,Android.Resource.Layout.SimpleSpinnerItem,dict.Values.ToArray());
adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
spinner.Adapter = adapter;
But when i trying to get the values, it displays: Tarjeta1 or Tarjeta2 instead 1 or 2
I hope anyone can support me.
Best regards.