Add an onClickListener on Default GroupIndicator in ExpandableListView
Asked Answered
I

4

6

I'm using Expandable List view. In my app both the group and child have content. So I need to start activity on groupClicked as well as on Child clicked. As the default action (given in android) when I click on a group the group expands.

I want to add a action on the group indicator button. So that, when the group is clicked the activity will start and when the group indicator button is clicked the child will be shown.

 > a group 
     child 1
     child 2...

How can I do that ?

Thank You

Inconveniency answered 15/2, 2012 at 12:53 Comment(2)
Just out of curiosity : what difference do you make between "showing the group's content" and "show the group's children" (based on this picture : bogotobogo.com/images/Android/Android7/SmplExpandable.png)?Artilleryman
I need to start activity for both group and child. Thanks for comment.Inconveniency
P
2

as far as I know, It is not possible to add any action on default button of expandable list.

Proclus answered 26/2, 2012 at 6:25 Comment(0)
T
1

you can set groupIndicator to null and then add a button to your group layout and handle whatever you want on the button onclicklistener

this link may help you to handle multiple listeners on one list item

CustomListView Example

and this one for ExpandableListView:

ExpandableListView Example

Tiros answered 9/8, 2012 at 11:11 Comment(0)
A
0

Using "findviewbyId" call id of group and child group into activity.Generate group and child group listviews in string.xml.Using onClickListener we can show group and childgroup

Abhor answered 18/2, 2012 at 8:12 Comment(0)
W
0

The following listener will run when a user clicks/taps on an indicator:

expandableListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
            @Override
            public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) {
                // add your code here ...
                return true;
            }
        });
Wittol answered 14/2, 2016 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.