Forum Xamarin.Android

Issue with getting text value from Spinner and datpicker (Solved)

AyhamNajemAyhamNajem USMember
edited June 2016 in Xamarin.Android


I have a problem with getting users chosen date from datepicker, It always send the default date to the database, but I need it to send what did the user choose.
This is what I wrote for the datepicker:

DatePicker dap = view.FindViewById(Resource.Id.datePicker);
String dapt;
int year = dap.Year;
int month = dap.Month + 1;
int day = dap.DayOfMonth;
dapt = day + "/" + month + "/" + year;

I'm facing the same problem with spinners items, I am getting also the first option and not the chosen one
This is the code for it:

Spinner ts = view.FindViewById(Resource.Id.spinner);
String tt;
tt = ts.SelectedItem.ToString();

So can anyone help me to solve this problem please?

Best Answer


  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭

    I don't know android very well but I think you have to test SelectedItem only inside a OnSelectedIndex raised event or something similar

Sign In or Register to comment.