Hello, i am new to Android and i try to build a list view with multiple checkboxs in. It seems to work but it's not working. When i click a checkbox i have the good event on the good position the first time. the second time, it raises two events for only one click with a good position and a bad one. After, it raises 4, 8 , ...events abd not only one. This is the view code :
public override View GetView(int position, View convertView, ViewGroup parent) { var item = items[position];
View view = convertView;
if (view == null) // no view to re-use, create new
{
view = context.LayoutInflater.Inflate(Resource.Layout.LayRowTestListView, null);
}
TextView myString1 = view.FindViewById<TextView>(Resource.Id.TEST_String1);
myString1.Text = item.myString1;
TextView myString2 = view.FindViewById<TextView>(Resource.Id.TEST_String2);
myString2.Text = item.myString2;
CheckBox myCheckBoxA = view.FindViewById<CheckBox>(Resource.Id.TESTCheckBoxA);
myCheckBoxA.Checked = item.myCheckBoxA.Checked;
//here, the event which works good for the first click, had 2 events for one click the second time, and multiple events after..
// with bad poistions after the first clcik
myCheckBoxA.CheckedChange += (sender, e) =>
{
Toast.MakeText(context, "position = " + position.ToString() + "string1 = " + myString1, ToastLength.Short).Show();
item.myCheckBoxA.Checked = !item.myCheckBoxA.Checked;
};
CheckBox myCheckBoxB = view.FindViewById<CheckBox>(Resource.Id.TESTCheckBoxB);
myCheckBoxB.Checked = item.myCheckBoxB.Checked;
CheckBox myCheckBoxC = view.FindViewById<CheckBox>(Resource.Id.TESTCheckBoxC);
myCheckBoxC.Checked = item.myCheckBoxC.Checked;
return view;
}
I saw no sample with objects like multiple checkbox or buttons or spinner... in a custom listview with events. Any idear ? Thanks