Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Android
  4. ExpandableListView ChildView button click event fires on multiple ChildView buttons

ExpandableListView ChildView button click event fires on multiple ChildView buttons

Scheduled Pinned Locked Moved Android
helplearning
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GuyThiebaut
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups