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 7908141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:47:23+00:00 2026-06-03T11:47:23+00:00

Does anyone have an examples for using the BaseExpandableListAdapter with Mono for Android. I’m

  • 0

Does anyone have an examples for using the BaseExpandableListAdapter with Mono for Android. I’m trying to implement this for one of my views, but am having issues with finding something that is thorough. Can anyone provide any examples on how they got this working with Mono for Android?

  • 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-03T11:47:25+00:00Added an answer on June 3, 2026 at 11:47 am

    Here’s an admittedly crude looking but functional example of using a custom expandable list adapter. You can think of the data source as being a list of lists, since each item will expand to display a list of items underneath it. To represent that, we’ll use this simple model:

    public class Group : Java.Lang.Object
    {
        public string Name { get; set; }
        public IList<string> Items { get; set; }
    }
    

    Using that model you can then create a class that inherits from BaseExpandableListAdapter and implements all the required methods/properties:

    public class MyAdapter : BaseExpandableListAdapter
    {
        private readonly Context _context;
        private readonly IList<Group> _groups;
    
        public MyAdapter(Context context, IList<Group> groups)
        {
            _context = context;
            _groups = groups;
        }
    
        public override Java.Lang.Object GetChild(int groupPosition, int childPosition)
        {
            return _groups[groupPosition].Items[childPosition];
        }
    
        public override long GetChildId(int groupPosition, int childPosition)
        {
            return (groupPosition * _groups.Count) + childPosition;
        }
    
        public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
        {
            var view = (TextView)(convertView ?? new TextView(_context));
    
            view.Text = _groups[groupPosition].Items[childPosition];
    
            return view;
        }
    
        public override int GetChildrenCount(int groupPosition)
        {
            return _groups[groupPosition].Items.Count;
        }
    
        public override Java.Lang.Object GetGroup(int groupPosition)
        {
            return _groups[groupPosition];
        }
    
        public override long GetGroupId(int groupPosition)
        {
            return groupPosition;
        }
    
        public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
        {
            var view = (TextView)(convertView ?? new TextView(_context));
    
            view.Text = _groups[groupPosition].Name;
    
            return view;
        }
    
        public override bool IsChildSelectable(int groupPosition, int childPosition)
        {
            return true;
        }
    
        public override int GroupCount
        {
            get { return _groups.Count; }
        }
    
        public override bool HasStableIds
        {
            get { return true; }
        }
    }
    

    The constructor for the adapter takes in a list of groups, and uses that to implement the methods that ask for a group, item, etc. To keep things simple, for each view I’m just rendering a single TextView but you can create/inflate any view you want for the items.

    To demonstrate this in action, here’s a sample activity that will load up an expandable list with some data:

    [Activity(Label = "ExpandableListDemo", MainLauncher = true, Icon = "@drawable/icon")]
    public class MyExpandableListActivity : ExpandableListActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
    
            var groups = new List<Group>
                             {
                                 new Group
                                     {
                                         Name = "Group 1",
                                         Items = new List<string> { "Item 1.1", "Item 1.2", "Item 1.3" }
                                     },
                                new Group
                                     {
                                         Name = "Group 2",
                                         Items = new List<string> { "Item 2.1", "Item 2.2", "Item 2.3" }
                                     }
                             };
    
            var adapter = new MyAdapter(this, groups);
    
            SetListAdapter(adapter);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

does anyone have any examples of using NSKeyedArchiver in monotouch? i just want to
Scenario Does anyone have any good examples of peer-to-peer (p2p) networking in C++ using
Does anyone have specific examples of using the Ivy <deliver> or <publish> tasks with
Does anyone have any examples of using Sqlite with ASP.NET membership? I am building
What's the purpose of using Singleton Enforced classes and does anyone have any examples
Does anyone have a link to a learning resource for using Invoke? I'm trying
Does anyone have a working example of a video player built using Qt phonon?
Does anyone have examples/tutorials of exception handling in R? The official documentation is very
Does anyone know of WPF code examples using Prism in which modules each register
Does anyone have any examples of starting the file stream before the rendering/building process

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.