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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T13:04:39+00:00 2026-06-04T13:04:39+00:00

I try so many times but why I cann’t do it I don’t know.

  • 0

I try so many times but why I cann’t do it I don’t know. After I declare Expandable List view this:

listView =(ExpandableListView)findViewById(R.id.expandableListView1);

And I create My adapter as like ;

public class MyExpandableListAdapter extends BaseExpandableListAdapter {
        // Sample data set.  children[i] contains the children (String[]) for groups[i].
        private String[] groups = { "People Names", "Dog Names", "Cat Names", "Fish Names" };
        private String[][] children = {
                { "Arnold", "Barry", "Chuck", "David" },
                { "Ace", "Bandit", "Cha-Cha", "Deuce" },
                { "Fluffy", "Snuggles" },
                { "Goldy", "Bubbles" }
        };

        public Object getChild(int groupPosition, int childPosition) {
            return children[groupPosition][childPosition];
        }

        public long getChildId(int groupPosition, int childPosition) {
            return childPosition;
        }

        public int getChildrenCount(int groupPosition) {
            return children[groupPosition].length;
        }

        public TextView getGenericView() {
            // Layout parameters for the ExpandableListView
            AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                    ViewGroup.LayoutParams.FILL_PARENT, 64);

            TextView textView = new TextView(ExpandableList1.this);
            textView.setLayoutParams(lp);
            // Center the text vertically
            textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
            // Set the text starting position
            textView.setPadding(36, 0, 0, 0);
            return textView;
        }

        public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
                View convertView, ViewGroup parent) {
            TextView textView = getGenericView();
            textView.setText(getChild(groupPosition, childPosition).toString());
            return textView;
        }

        public Object getGroup(int groupPosition) {
            return groups[groupPosition];
        }

        public int getGroupCount() {
            return groups.length;
        }

        public long getGroupId(int groupPosition) {
            return groupPosition;
        }

        public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
                ViewGroup parent) {
            TextView textView = getGenericView();
            textView.setText(getGroup(groupPosition).toString());
            return textView;
        }

        public boolean isChildSelectable(int groupPosition, int childPosition) {
            return true;
        }

        public boolean hasStableIds() {
            return true;
        }

    }

And then I set my adapter to listView.

mAdapter = new MyExpandableListAdapter();
        setListAdapter(mAdapter);

But There is so many problem I cannot create ;
İf u help me I will be so happy.
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-04T13:04:41+00:00Added an answer on June 4, 2026 at 1:04 pm

    Ok. Thanks guyss I handle my problem, all problem is that don’t extends ExpandableListActivity, just Activity it is my code. Now I try to learn how to focus group when a click a button.
    Here is code.

    public class expandXml extends Activity{
    
    ExpandableListView listView;
    ExpandableListAdapter adapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.deneme2);
    
    
        listView =(ExpandableListView)findViewById(R.id.expandableListView1);
        listView.setFocusable(true);
         adapter = new ExpandableListAdapter() {
    
    
            private String[] groups = { "People Names", "Dog Names", "Cat Names", "Fish Names" };
            private String[][] children = {
                    { "Arnold", "Barry", "Chuck", "David" },
                    { "Ace", "Bandit", "Cha-Cha", "Deuce" },
                    { "Fluffy", "Snuggles" },
                    { "Goldy", "Bubbles" }
            };
            public void unregisterDataSetObserver(DataSetObserver observer) {
                // TODO Auto-generated method stub
    
            }
    
            public void registerDataSetObserver(DataSetObserver observer) {
                // TODO Auto-generated method stub
    
            }
    
            public void onGroupExpanded(int groupPosition) {
                // TODO Auto-generated method stub
    
            }
    
            public void onGroupCollapsed(int groupPosition) {
                // TODO Auto-generated method stub
    
            }
    
            public boolean isEmpty() {
                // TODO Auto-generated method stub
                return false;
            }
    
            public boolean isChildSelectable(int groupPosition, int childPosition) {
                // TODO Auto-generated method stub
                return true;
            }
    
            public boolean hasStableIds() {
                // TODO Auto-generated method stub
                return true;
            }
    
            public View getGroupView(int groupPosition, boolean isExpanded,
                    View convertView, ViewGroup parent) {
                 TextView textView = getGenericView();
                    textView.setText(getGroup(groupPosition).toString());
                    return textView;
            }
    
            public long getGroupId(int groupPosition) {
                // TODO Auto-generated method stub
                return groupPosition;
            }
    
            public int getGroupCount() {
                // TODO Auto-generated method stub
                return groups.length;
            }
    
            public Object getGroup(int groupPosition) {
                // TODO Auto-generated method stub
                return groups[groupPosition];
            }
    
            public long getCombinedGroupId(long groupId) {
                // TODO Auto-generated method stub
                return 0;
            }
    
            public long getCombinedChildId(long groupId, long childId) {
                // TODO Auto-generated method stub
                return 0;
            }
    
            public int getChildrenCount(int groupPosition) {
                // TODO Auto-generated method stub
                return children[groupPosition].length;
            }
    
            public View getChildView(int groupPosition, int childPosition,
                    boolean isLastChild, View convertView, ViewGroup parent) {
                 TextView textView = getGenericView();
                    textView.setText(getChild(groupPosition, childPosition).toString());
                    return textView;
            }
    
            public long getChildId(int groupPosition, int childPosition) {
                // TODO Auto-generated method stub
                return childPosition;
            }
    
            public Object getChild(int groupPosition, int childPosition) {
                // TODO Auto-generated method stub
                return children[groupPosition][childPosition];
            }
    
            public boolean areAllItemsEnabled() {
                // TODO Auto-generated method stub
                return false;
            }
    
            public TextView getGenericView() {
                // Layout parameters for the ExpandableListView
                AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
                        ViewGroup.LayoutParams.FILL_PARENT, 64);
    
                TextView textView = new TextView(expandXml.this);
                textView.setLayoutParams(lp);
                // Center the text vertically
                textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
                // Set the text starting position
                textView.setPadding(36, 0, 0, 0);
    
                return textView;
            }
    
        };
        listView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
    
            public boolean onChildClick(ExpandableListView parent, View v,
                    int groupPosition, int childPosition, long id) {
    
                Object x =adapter.getChild(groupPosition, childPosition);
    
                //Object o = this.getExpandableListAdapter().getChild(groupPosition, childPosition);
                String key =x.toString();
                 Toast.makeText(expandXml.this,"Secildi "+key ,Toast.LENGTH_LONG).show();       
                return true;
            }
        });
        Button butex = (Button)findViewById(R.id.button1);
        butex.setOnClickListener(expandgroup);
    
    
    
        listView.setAdapter(adapter);
    
    }
    private OnClickListener expandgroup = new OnClickListener() {
    
        public void onClick(View v) {
            // TODO Auto-generated method stub
            listView.expandGroup(3);
    
    
    
        }
    }; }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've searched around for the answer to this many times, but I don't know
I know this has been asked and answered many times in this forum. But
I know that this question has a been asked many times, but I still
I know this question has been asked many times over, but I am currently
I know this question is posted many times, but I want to ask about
I know this has been asked many times, and answered many times, but, all
I know that this has been asked many times before, but I believe my
I already posted this issue but had edited it so many times I thought
This question has been brought up many times, but I'd like to ask it
I know this question has been asked numerous times but I couldn't find a

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.