Im trying to create a Spinners within a ListView, but i dont know how to get all the values of each spinner in a List of strings for example. This is the code of the Adapter:
public class CustomizeColumnsListAdapter : BaseAdapter
{
private Activity context;
private int columnsCount;
public List<string> fieldsValues;
public CustomizeColumnsListAdapter(Activity context, int columnsCount)
{
this.context = context;
this.dataObject = dataObject;
this.columnsCount = columnsCount;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
RelativeLayout view = (convertView
?? context.LayoutInflater.Inflate(
Resource.Layout.customize_column_list_item, parent, false)
) as RelativeLayout;
try
{
string[] sortingColumsItems = {"None", "Id", "Customer Name", "Customer Number", "City", "Address", "Credit Limit", "Contact Name", "Phone Number", "Mail"};
ArrayAdapter<string> spinnerArrayAdapter = new ArrayAdapter<string>(context, Android.Resource.Layout.SimpleSpinnerItem, sortingColumsItems);
spinnerArrayAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
view.FindViewById<Spinner>(Resource.Id.cboCCD).Adapter = spinnerArrayAdapter;
view.FindViewById<Spinner>(Resource.Id.cboCCD).Enabled = true;
if(columnsCount>=position)
{
string columnIndex = (position + 1).ToString();
view.FindViewById<TextView>(Resource.Id.lblColumn).Text = columnIndex;
}
}
catch (System.Exception ex)
{
Toast.MakeText(context, ex.ToString(), ToastLength.Short).Show();
}
return view;
}
public override int Count
{
get { return columnsCount; }
}
public override Java.Lang.Object GetItem(int position)
{
return null;
}
public override long GetItemId(int position)
{
return position;
}