ExpandableListView ChildView button click event fires on multiple ChildView buttons
-
I have an ExpandableListView is using an adapter that inherits from the BaseExpandableListAdapter base class. On the childview I have a button, in this case with an id of HelloWorld. When I click on the HelloWorld button and the Click event is fired, the Click event is also fired for other HelloWorld buttons not on this childview, the Toast is displaying more than one group when I expect only one to be displayed. What I am expecting is for only one Click event to be fired and that event to be associated with the button I click on the childview the button is on. So there is obviously something I am not understanding here. I have spent an hour googling but cannot find anything that points to what I am getting wrong. Any pointers or help much appreciated
public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
{
if (convertView == null)
{
convertView = _context.LayoutInflater.Inflate(Resource.Layout.ListItemCustomLayout, null);
}var button = (Button)convertView.FindViewById(Resource.Id.HelloWorld); button.SetFocusable(ViewFocusability.NotFocusable); button.Click += (sender, e) => { var groupName = ((Models.Timer)(((JavaObjectWrapper)GetChild(groupPosition, childPosition)).Obj)).GroupName; Toast.MakeText(\_context, groupName, ToastLength.Long).Show(); }; return convertView; }
“That which can be asserted without evidence, can be dismissed without evidence.”
― Christopher Hitchens