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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:11:58+00:00 2026-06-13T23:11:58+00:00

I have found this code in internet, an example of ExpandableListView . And it

  • 0

I have found this code in internet, an example of ExpandableListView. And it runs perfectly.

import android.app.ExpandableListActivity;
import android.os.Bundle;
import android.widget.ExpandableListAdapter;
import android.widget.SimpleExpandableListAdapter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Demonstrates expandable lists backed by a Simple Map-based adapter
 */
public class SmplExpandableTest extends ExpandableListActivity {
    private static final String PARENT_KEY = "pKey";
    private static final String CHILD_KEY = "cKey";

    private ExpandableListAdapter mAdapter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
        List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();

        Map<String, String> curGroupMap = new HashMap<String, String>();
        groupData.add(curGroupMap);
        curGroupMap.put(PARENT_KEY, "Hello");
        curGroupMap.put(CHILD_KEY, "First Order System Response");

        List<Map<String, String>> children = new ArrayList<Map<String, String>>();

        Map<String, String> curChildMap = new HashMap<String, String>();
        children.add(curChildMap);
        curChildMap.put(PARENT_KEY, "World");
        curChildMap.put(CHILD_KEY, "Second Order System");

        childData.add(children);

        // Set up our adapter
        mAdapter = new SimpleExpandableListAdapter(this, groupData,
                android.R.layout.simple_expandable_list_item_1, new String[] {
                        PARENT_KEY, CHILD_KEY }, new int[] {
                        android.R.id.text1, android.R.id.text2 }, childData,
                android.R.layout.simple_expandable_list_item_2, new String[] {
                        PARENT_KEY, CHILD_KEY }, new int[] {
                        android.R.id.text1, android.R.id.text2 });
        setListAdapter(mAdapter);
    }
}

Now i want to insert this ExpandableListView inside a layout, so that I can add a button at the bottom. How can I do this ?

Thanks

  • 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-13T23:11:58+00:00Added an answer on June 13, 2026 at 11:11 pm

    To add a Button to the bottom of your screen under ExpandableListView you have to do 2 things:

    1. The activity has to extend from Activity instead of ExpandableListActivity. And you have to set a custom layout.
    2. Create custom layout containing the ExpandableListView and the ‘Button`.

    The activity would be something like:

    public class SmplExpandableTest extends Activity {
        private static final String PARENT_KEY = "pKey";
        private static final String CHILD_KEY = "cKey";
    
        private ExpandableListAdapter mAdapter;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.my_layout);
            ExpandableListView elv = (ExpandableListView) findViewById(R.id.elv);
    
            List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
            List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
    
            Map<String, String> curGroupMap = new HashMap<String, String>();
            groupData.add(curGroupMap);
            curGroupMap.put(PARENT_KEY, "Hello");
            curGroupMap.put(CHILD_KEY, "First Order System Response");
    
            List<Map<String, String>> children = new ArrayList<Map<String, String>>();
    
            Map<String, String> curChildMap = new HashMap<String, String>();
            children.add(curChildMap);
            curChildMap.put(PARENT_KEY, "World");
            curChildMap.put(CHILD_KEY, "Second Order System");
    
            childData.add(children);
    
            // Set up our adapter
            mAdapter = new SimpleExpandableListAdapter(this, groupData,
                    android.R.layout.simple_expandable_list_item_1, new String[] {
                            PARENT_KEY, CHILD_KEY }, new int[] {
                            android.R.id.text1, android.R.id.text2 }, childData,
                    android.R.layout.simple_expandable_list_item_2, new String[] {
                            PARENT_KEY, CHILD_KEY }, new int[] {
                            android.R.id.text1, android.R.id.text2 });
    
            elv.setAdapter(mAdapter);
        }
    }
    

    Layout res/layout/my_layout.xml would be something like:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
            <ExpandableListView 
                android:layout_width="match_parent"
                android:layout_height="0dp"
                android:layout_weight="1"
                android:id="@+id/elv" >
            </ExpandableListView>
            <Button 
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:id="@+id/btn"
                android:text="@string/btn_text" >
    </LinearLayout>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found this line of MatLab code on the internet that displays a
Hi i have problem with this code, i found it on the internet and
I found this PHP code in an app I have to modify... $links =
I've got this code from an example I found useful around Internet. It uses
I have found this code for reverse geocoding: var point = new GLatLng (lat[1],long[1]);
I have found this project on Codeplex. http://www.codeplex.com/ProjNET I need to integrate this code
I want to force the download of an image. I have found this code:
I have found this line of code in a game that I study int
I have found this piece of code in the Haskell sendfile package: http://patch-tag.com/r/mae/sendfile/snapshot/current/content/pretty/src/Network/Socket/SendFile/Linux.hsc --
I have this code which I have found from google. It's a adapter for

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.