I'm using an expandable list view where an user can select data.
The user can select either the group, either the child. To facilitate the distinction between the 2, I have a radio group with 2 options :
What I need, is to hide the group indicator on the second case, and then restore it when the first option is selected.
Here is my code :
rgLink.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if(checkedId == R.id.rb_link_subject){ //Here is the child mode
mLinkType = LINK_SUBJECT;
//elvSubject.setGroupIndicator(/*Here I need the default group indicator*/);
}
else{ //Here is the group mode
collapseAllChildren();
//The line below hide the group indicator
elvSubject.setGroupIndicator(null);
mLinkType = LINK_CATEGORY;
}
}
});
I'm also using, for the group item :
style="?android:attr/listSeparatorTextViewStyle"
So basically, I just need a one line code to restore the default group indicator. How can I do this ?
You can obtain an attribute from the current theme:
//obtain expandableListViewStyle from theme
TypedArray expandableListViewStyle = context.getTheme().obtainStyledAttributes(new int[]{android.R.attr.expandableListViewStyle});
//obtain attr from style
TypedArray groupIndicator = context.getTheme().obtainStyledAttributes(expandableListViewStyle.getResourceId(0,0),new int[]{android.R.attr.groupIndicator});
elvSubject.setGroupIndicator(groupIndicator.getDrawable(0));
expandableListViewStyle.recycle();
groupIndicator.recycle();
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