protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.Signup_Car); client = new HttpClient(); client.BaseAddress = new Uri(GetString(Resource.String.RestAPIBaseAddress)); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); progress = new Android.App.ProgressDialog(this); progress.Indeterminate = true; progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner); progress.SetMessage("Registering Account....."); progress.SetCancelable(false); iMember = JsonConvert.DeserializeObject <Member>(Intent.GetStringExtra("Member")); spnMake = (Spinner)FindViewById(Resource.Id.carmake); spnModel = (Spinner)FindViewById(Resource.Id.signup_carmodel); spnColor = (Spinner)FindViewById(Resource.Id.signup_carcolor); etCarplate = (EditText)FindViewById(Resource.Id.carplate); btnSignup = (TextView)FindViewById(Resource.Id.signupcarbtn); btnSignup.Click += SignupClick; var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.car_color_array, Resource.Layout.Custom_Spinner_Signup); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spnColor.Adapter = adapter; spnMake.ItemSelected += async(sender, e) => { var makeList = await RESTClient.GetCarmodelMakeAsync(this, spnMake.SelectedItem.ToString().Trim()); Array.Sort(makeList); ArrayAdapter <string> dataAdapter = new ArrayAdapter <string>(this, Resource.Layout.Custom_Spinner_Signup, makeList); dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spnModel.Adapter = dataAdapter; }; InitializeMakeSpinner(); }
private async void InitializeVehicleSpinners() { RunOnUiThread(() => { progress.Show(); }); var modelList = await RESTClient.GetCarmodelAsync(this); RunOnUiThread(() => { progress.Dismiss(); }); Array.Sort(modelList); ArrayAdapter <string> dataAdapter = new ArrayAdapter <string>(this, Resource.Layout.Custom_Spinner_Edit_Details, modelList); dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spnMake.Adapter = dataAdapter; spnMake.SetSelection(dataAdapter.GetPosition(user.Vehicles[0].make)); spnMake.ItemSelected += async(sender, e) => { var makeList = await RESTClient.GetCarmodelMakeAsync(this, spnMake.SelectedItem.ToString().Trim()); Array.Sort(makeList); dataAdapter = new ArrayAdapter <string>(this, Resource.Layout.Custom_Spinner_Edit_Details, makeList); dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spnModel.Adapter = dataAdapter; spnModel.SetSelection(dataAdapter.GetPosition(user.Vehicles[0].model)); }; var adapter = ArrayAdapter.CreateFromResource(this, Resource.Array.car_color_array, Resource.Layout.Custom_Spinner_Edit_Details); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); spnColor.Adapter = adapter; spnColor.SetSelection(adapter.GetPosition(user.Vehicles[0].color)); }