Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:13:35+00:00 2026-06-04T03:13:35+00:00

I am having an issue that I have spend way too much time trying

  • 0

I am having an issue that I have spend way too much time trying to figure out. I can’t get the OnChildClick listener to fire when one of the child items in my ExpandableListAdapter is clicked.

It was my understanding that the overridden OnChildClick event of the ViewCheckListActivity.cs file below should fire when one of the rows of the children are clicked. I’m sure that I am missing something silly, but was wondering if anyone had any experience and could point me in the right direction for getting this working.

Code is all listed below:

CheckListItem_Group.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/loGroup"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="horizontal"
  android:minWidth="25px"
  android:minHeight="25px">
  <CheckedTextView
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:layout_marginLeft="20px"
      android:paddingLeft="35dip"
      android:textStyle="bold"
      android:textSize="14dip"
      android:gravity="center_vertical"
      android:layout_gravity="right"
      android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
      android:id="@+id/chkCheckList" />
</LinearLayout>

CheckListItem_Item.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/loItem"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:minWidth="25px"
    android:minHeight="25px">
    <CheckedTextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="20px"
        android:paddingLeft="35dip"
        android:textStyle="bold"
        android:textSize="14dip"
        android:gravity="center_vertical"
        android:layout_gravity="right"
        android:clickable="false"
        android:focusable="true"
        android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
        android:id="@+id/chkCheckListItem" />
</LinearLayout>

ViewCheckListActivity.cs

public class ViewCheckListActivity : ExpandableListActivity
{
    private Int32? _checkListId;
    protected static DiversLogDao Dao;

    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        var checkListItems = Dao.GetCheckListItems(_checkListId.Value);

        var adapter = new CheckListItemAdapter(this, checkListItems);
        SetListAdapter(adapter);

        ExpandableListView.ChoiceMode = ChoiceMode.Multiple;
        ExpandableListView.SetOnChildClickListener(this);
    }

    public override bool OnChildClick (ExpandableListView parent, View v, int groupPosition, int childPosition, long id)
    {
        return base.OnChildClick (parent, v, groupPosition, childPosition, id);
    }
}

CheckListItemAdapter.cs

public class CheckListItemAdapter : BaseExpandableListAdapter
{
    private readonly List<Item> _checkListItems;
    public readonly Activity Context;

    public CheckListItemAdapter(Activity context, List<CheckListItem> checkListItems)
    {
        _checkListItems =
            checkListItems.Where(i => i.ParentId == null)
                .Select(i => new Item
                                    {
                                        Id = i.Id,
                                        Name = i.Name,
                                        Description = i.Description,
                                        ChildItems = checkListItems.Where(c => c.ParentId == i.Id)
                                            .Select(c => new ChildItem
                                                            {
                                                                Id = c.Id,
                                                                CheckListId = c.CheckListId,
                                                                ParentId = c.ParentId,
                                                                Name = c.Name,
                                                                Description = c.Description,
                                                                LastUpdated = c.LastUpdated,
                                                                Checked = false
                                                            }).ToList()
                                    }).ToList();
        Context = context;
    }

    public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
    {
        if (convertView == null)
        {
            convertView = Context.LayoutInflater.Inflate(Resource.Layout.CheckListItem_Group, null) as LinearLayout;
        }

        if (convertView != null)
        {
            var checkList = convertView.FindViewById<CheckedTextView>(Resource.Id.chkCheckList);
            checkList.SetText(_checkListItems[groupPosition].Name, TextView.BufferType.Normal);
            checkList.Checked = _checkListItems[groupPosition].AllChildrenChecked();
        }

        return convertView;
    }

    public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
    {
        if(convertView == null)
        {
            convertView = Context.LayoutInflater.Inflate(Resource.Layout.CheckListItem_Item, parent, false) as LinearLayout;
        }

        if (convertView != null)
        {
            var checkListItem = convertView.FindViewById<CheckedTextView>(Resource.Id.chkCheckListItem);
            checkListItem.SetText(_checkListItems[groupPosition].ChildItems[childPosition].Name, TextView.BufferType.Normal);
            checkListItem.Checked = _checkListItems[groupPosition].ChildItems[childPosition].Checked;
            checkListItem.Tag = _checkListItems[groupPosition].ChildItems[childPosition];

            checkListItem.Click -= CheckListItemClick;
            checkListItem.Click += CheckListItemClick;
        }

        return convertView;
    }

    protected void CheckListItemClick(object sender, EventArgs e)
    {
        var chkItem = sender as CheckedTextView;

        if (chkItem == null) return;

        chkItem.Toggle();

        var childItem = chkItem.Tag as ChildItem;

        if (childItem == null) return;

        childItem.Checked = chkItem.Checked;
    }

    public override Object GetChild(int groupPosition, int childPosition)
    {
        return _checkListItems[groupPosition].ChildItems[childPosition];
    }

    public override long GetChildId(int groupPosition, int childPosition)
    {
        return _checkListItems[groupPosition].ChildItems[childPosition].Id;
    }

    public override int GetChildrenCount(int groupPosition)
    {
        return _checkListItems[groupPosition].ChildItems.Count();
    }

    public override Object GetGroup(int groupPosition)
    {
        return _checkListItems[groupPosition];
    }

    public override long GetGroupId(int groupPosition)
    {
        return _checkListItems[groupPosition].Id;
    }

    public override bool IsChildSelectable(int groupPosition, int childPosition)
    {
        return true;
    }

    public override int GroupCount
    {
        get { return _checkListItems.Count(); }
    }

    public override bool HasStableIds
    {
        get { return true; }
    }

    private class Item : Object
    {
        public Int32 Id { get; set; }
        public String Name { get; set; }
        public String Description { get; set; }
        public List<ChildItem> ChildItems { get; set; } 

        public bool AllChildrenChecked()
        {
            return ChildItems.All(i => i.Checked);
        }
    }

    private class ChildItem : Object
    {
        public Int32 Id { get; set; }
        public Int32 CheckListId { get; set; }
        public Int32? ParentId { get; set; }
        public String Name { get; set; }
        public String Description { get; set; }
        public DateTime LastUpdated { get; set; }
        public Boolean Checked { get; set; }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:13:36+00:00Added an answer on June 4, 2026 at 3:13 am

    I was able to finally get this working. Here is what I did to get it working.

    The first was to add the focusable attribute to the layouts items as shown below:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/loItem"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:focusable="false"
        android:minWidth="25px"
        android:minHeight="25px">
        <CheckedTextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20px"
            android:paddingLeft="35dip"
            android:textStyle="bold"
            android:textSize="14dip"
            android:gravity="center_vertical"
            android:layout_gravity="right"
            android:focusable="false"
            android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
            android:id="@+id/chkCheckListItem" />
    </LinearLayout>
    

    And

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/loGroup"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal"
      android:focusable="false"
      android:minWidth="25px"
      android:minHeight="25px">
      <CheckedTextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_marginLeft="20px"
          android:paddingLeft="35dip"
          android:textStyle="bold"
          android:textSize="14dip"
          android:gravity="center_vertical"
          android:layout_gravity="right"
          android:focusable="false"      
          android:drawableRight="?android:attr/listChoiceIndicatorMultiple"
          android:id="@+id/chkCheckList" />
    </LinearLayout>
    

    Doing that alone didn’t fix the issue. The next thing is the removable of the click event added to the checkbox list.

    checkListItem.Click -= CheckListItemClick;
    checkListItem.Click += CheckListItemClick;
    

    Doing those 2 changes allowed the event to propagate all the way up to the activity itself.

    I just hope that this information will help someone else out in the future. Not sure if this is as designed or not.

    Chaitanya Marvici

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having an issue here that I have tried everything I can think of but
I'm having an issue where I have a player object that I'm trying to
I am having some problems figuring out this issue. I have a server that
I am having an issue with somethign that I thoguth woudl have been simple.
I have been having an issue with the $this->delete() method that deletes a record
I am having this issue. I have a script that checks if variable exists,
I am having an issue with my TextView. I have a PlayScreenActivity that displays
I'm having an issue with backbone.js' models. I have a view that creates another
Here is the issue I am having: I have a large query that needs
I'm having an issue using a new WPF app that is trying to display

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.