Qing Ryder

Qing Ryder

  • NA
  • 202
  • 17.4k

Manipulating multiple spinner in a fragment and display resu

May 29 2018 6:04 PM

Hello Coders!

I have a spinner with list of elements in an arrays asin

  1. spinner.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelected);  
  2. var adapter = ArrayAdapter.CreateFromResource(  
  3. view.Context, Resource.Array.planets_array, Android.Resource.Layout.SimpleSpinnerItem);  
  4.   
  5.         adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);  
  6.         spinner.Adapter = adapter; 
when a User clicks on an Item in the spinner lets say Brake, it Populates the second spinner with attributes of brake asin
  1. private void spinner_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)  
  2.         {  
  3.             int resourceID = 1;  
  4.             switch (e.Position)//position is the array index    
  5.             {  
  6.                 case 1: //Brakes    
  7.                     resourceID = Resource.Array.plane_array;  
  8.                     break;  
  9.                 case 2: //Check engine and warning lights  
  10.                     resourceID = Resource.Array.plan_array;  
  11.                     break;  
  12.                 case 3: //electricals    
  13.                     resourceID = Resource.Array.elec_array;  
  14.                     break;  
  15.                 case 4: //engine and peformance  
  16.                     resourceID = Resource.Array.plana_array;  
  17.                     break;  
  18.                 case 5: //Heating and air-conditioning  
  19.                     resourceID = Resource.Array.planc_array;  
  20.                     break;  
  21.                 case 6: //lights  
  22.                     resourceID = Resource.Array.light_array;  
  23.                     break;  
  24.                 case 7: //steering and handling  
  25.                     resourceID = Resource.Array.hand_array;  
  26.                     break;  
  27.                 case 8: //Tires and wheel  
  28.                     resourceID = Resource.Array.tire_array;  
  29.                     break;  
  30.                 case 9: //Transmission  
  31.                     resourceID = Resource.Array.trans_array;  
  32.                     break;  
  33.             }  
  34.   
  35.             if (resourceID > 1)  
  36.             {  
  37.                 var adapter = ArrayAdapter.CreateFromResource(  
  38.                     e.View.Context, resourceID, Android.Resource.Layout.SimpleSpinnerItem);  
  39.   
  40.                 adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);  
  41.                 spinner1.Adapter = adapter;  
  42.             }  
  43.             else  
  44.                 spinner1.Adapter = null;  
  45.         } 

Now, the idea is that on the second spinner, when an attribute is being clicked, lets say "Brake is Worn Out"
i want to populate a Textview in another fragment to show a result on ButtonClick.

please how do i set the spinner2 to know what is clicked and how to Populate the textview

please Somebody/Anybody should help me out

 
 
 

Answers (1)