Closed ashwini-pandarkat1993 closed 7 years ago
@ashwini-pandarkat1993 Did you get a solution?
Hiya! Here is one solution:
private ExpandableGroup expandedGroup;
adapter.setOnGroupExpandCollapseListener(new GroupExpandCollapseListener() {
@Override
public void onGroupExpanded(ExpandableGroup group) {
if (expandedGroup != null) {
adapter.toggleGroup(expandedGroup);
}
expandedGroup = group;
}
@Override
public void onGroupCollapsed(ExpandableGroup group) {
}
});
Thank you very much!
2017-01-27 6:34 GMT+06:00 Amanda Hill notifications@github.com:
Closed #25 https://github.com/thoughtbot/expandable-recycler-view/issues/25.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/thoughtbot/expandable-recycler-view/issues/25#event-938682201, or mute the thread https://github.com/notifications/unsubscribe-auth/APfNKMAjS5jBGpJ2cRkh-5BRrXmGIYQNks5rWTuwgaJpZM4K9jA5 .
-- С уважением, Айтымбет Еламан
what should be written in adapter.toggleGroup(expandedGroup). As only integer value can be invoked into toggleGroup(int flatPos). how to get the position of an expanded group.
@JayattamaPrusty there is also a method to pass an ExpandableGroup
into toggleGroup()
@mandybess its not working for me.here i m facing a problem that when i expand one group,if i try to expand another group,its not expanding.after collapsing first group also no other groups not working.
how to add onclicklistener on child item?
Hi @mandybess, This code is working for me,but after adding this code in setOnGroupExpandCollapseListener method I'm getting crass after clicking two three time of any items. Please help me.
@rahulyadav7001 change line to: if (expandedGroup != null && !expandedGroup.equals(group)) {
@rahulyadav7001 This should solve your problem:
private ExpandableGroup mLastExpandedGroup ; @Override public void onGroupExpanded(ExpandableGroup group) { if (mLastExpandedGroup != null && !mLastExpandedGroup.equals(group) && adapter.isGroupExpanded(mLastExpandedGroup)) { adapter.toggleGroup(mLastExpandedGroup); } mLastExpandedGroup = group; }
I too want to be able to close an expanded group automatically when another one is opened. I'm probably missing something here but I've implemented the onGroupExpanded() listener in the Activity in the sample in ExpandActivity and it works but the rotation of the up down arrow is done in the GenreViewHolder hence the group is collapsed correctly but I don't know how to get the GenreViewHolder to rotate the arrow. There appears to be no way to link the ExpandableGroup to the GenreViewHolder. adapter.setOnGroupExpandCollapseListener(new GroupExpandCollapseListener() { @Override public void onGroupExpanded(ExpandableGroup group) {
if (expandedGroup != null
&& !expandedGroup.equals(group)
&& adapter.isGroupExpanded(expandedGroup)) {
adapter.toggleGroup(expandedGroup);
}
expandedGroup = group;
}
can some one help me with this
@mandybess its not working for me.here i m facing a problem that when i expand one group,if i try to expand another group,its not expanding.after collapsing first group also no other groups not working.
ya i am facing this issue too
Best solution.
` private ExpandableGroup expandedGroup;
productAdapter.setOnGroupExpandCollapseListener(new GroupExpandCollapseListener() {
@Override
public void onGroupExpanded(ExpandableGroup group) {
if (expandedGroup != null) {
productAdapter.toggleGroup(expandedGroup);
}
expandedGroup = group;
}
@Override
public void onGroupCollapsed(ExpandableGroup group) {
expandedGroup=null;
}
});
expandableRecyclerView.setAdapter(productAdapter);
}`
Hi, I want expand only one item at a time when I click on another list item previous should automatically collapse.