i have in my RecylcerViewAdapter a Spinner, with a SpinnerAdapter, because i have Checkbox - TextView, with dynamic Items.
I want to recognize in my RecylcerViewAdapter, when a SpinnerItem checked, to do things in my RecyclerViewAdapter. The View works fine.
How i add:
AdditionSpinnerAdapter adapter = new AdditionSpinnerAdapter(context, 0, categoryProductAddition.Product_Additions);
vh.AdditionSpinner.Adapter = adapter;
My SpinnerAdapter
namespace AndroidRegFirstApp.Adapter
{
public class AdditionSpinnerAdapter : ArrayAdapter<ProductAddition>
{
private Context mContext;
private List<ProductAddition> additions;
public AdditionSpinnerAdapter(Context context, int resource, List<ProductAddition> objects) :base (context, resource, objects)
{
this.mContext = context;
this.additions = objects;
}
public override View GetDropDownView(int position, View convertView, ViewGroup parent)
{
return this.GetCustomView(position, convertView, parent);
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
return this.GetCustomView(position, convertView, parent);
}
public View GetCustomView(int position, View convertView, ViewGroup parent)
{
LayoutInflater inflater = LayoutInflater.From(mContext);
convertView = inflater.Inflate(Resource.Layout.additionSpinnerItem, null);
TextView AdditionText = convertView.FindViewById<TextView>(Resource.Id.additionText);
CheckBox AdditionSelected = convertView.FindViewById<CheckBox>(Resource.Id.additionSelected);
AdditionText.Text = additions[position].Product_Addition_Name;
AdditionSelected.Checked = additions[position].Product_Addition_Selected;
AdditionSelected.Tag = position;
if (position == 0)
{
AdditionSelected.Visibility = ViewStates.Gone;
}
AdditionSelected.SetOnCheckedChangeListener(new Interface.OnCheckedListener(additions));
return convertView;
}
}
}
My OnCheckedListener:
public OnCheckedListener(List<ProductAddition> list)
{
this.additions = list;
}
public void OnCheckedChanged(CompoundButton buttonView, bool isChecked)
{
int position = (int)buttonView.Tag;
this.additions[position].Product_Addition_Selected = isChecked;
}
Now i want to when the OnCheckedChanged is change the state, that a methode in my RecylcerViewAdapter calls.
Aucun commentaire:
Enregistrer un commentaire