I'm using an ExpandableListView and I'm unsuccessfully trying to move an image when expanding a group (the image being part of the group view).
Here is my code :
my_list_view.setOnGroupExpandListener(new OnGroupExpandListener()
{
@Override
public void onGroupExpand(int groupPosition)
{
Toast.makeText(getBaseContext(), "Group " + my_list_view.getGroupId(groupPosition), Toast.LENGTH_SHORT).show();
}
});
Basically my problem is : how can I access the expanded Group view, when the only variable I can use is groupPosition?
Any you-should-create-a-custom-adapter-like response won't be accepted. I already tried that and it doesn't work for my issue. What I need is to listen the onGroupExpand event.
What I eventually did is using the boolean isExpanded
you get for free in getGroupView
when you make a custom adapter. I was able to make things work the way I wanted with that, instead of doing it in the activity. If you save the context you get in the constructor, you can use that to get resources.
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (isExpanded) {
mContext.getResources().getDrawable(R.drawable.arrow)
doSomething();
}
else {
doSomethingElse();
}
}
That's a lot easier than my other answer (which was a bit buggy anyway), so forget about that one :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With