well i´m trying to create a ExpandableListView like Spotify it does... But i don´t have any idea how do disable the LinearLayout to act like a button (Expand the list) I have created a image which should describe what i like. I like to have the possibility to handle a click on the text / image (parent) as a normal interaction. A click on the right button should expand the list like in Spotify...
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
This is the onCreate from the ChannelList which extends ListFragment. It stores the data and generate a new Adapter if the Fragment is called.
On the Adapter i have the getGroupView Method which look like:
So if i register the ImageButton in the adapter it will call the onClick from the adapter. But in the onClick i do not know which group was clicked... If i do not register the button on any listener it will not call the onGroupClick from the ChannelList...
Not overly elegant solution but it helped me out:
I've preserved the original groupIndicator. I liked the behavior as it was.
On the groupItem layout I simply blocked the space with empty view so that the original groupIndicator was still clickable:
Than sneaked in callBack object while creating ExpandableListAdapter and hooked it onClick on the "category_name" (for both child and group elements)
All you have to do now is to initialize properly ExpandableListAdapter in master fragment class
This is a bit old question, but this answer might help someone.
If you want to expand/collapse group by clicking on specific
Button
or some otherView
, you have to get that Button ingetGroupView
method in your Adapter class. Then, inonClick
method of yourButton
you have, either to castparent
toExpandableListView
, or to pass List's reference in constructor when you create adapter.I prefer the first approach. Here's the code, assuming that you have one
TextView
and anImageView
that is the arrow. I've added changing the arrow state too.Additionally, you would like to disable expanding/collapsing in
onGroupClick
listener.There is another method, but the fairly bad one, and that is that you copy entire
Adapter
class inside the class where you createExpandableListView
and setAdapter
. But do not do that. Seriously! ;)