I am new to Android.
I have a ExpandableListView, where I have managed to highlight (persistent) the selected item/child. But when I click/touch the group, the highlighted item goes away and seems like list has been redrawn. In onGroupClick, I am try to keep the highlighted item highlighted, but even then it redraws the list.
@Override
public boolean onGroupClick(ExpandableListView parent, View v,
int groupPosition, long id) {
// TODO keepSelectedModuleHighlited. Right now its not working.
if (parent.isGroupExpanded(groupPosition)) {
parent.collapseGroup(groupPosition);
} else {
parent.expandGroup(groupPosition);
}
keepSelectedModuleHighlited();
return true;
}
And method : keepSelectedModuleHighlited
private void keepSelectedModuleHighlited() {
if (lastSelectedView != null && lastSelectedDrawble != null) {
lastSelectedView.setBackgroundDrawable(this.getResources()
.getDrawable(R.drawable.module_selected));
}
}
How can I put my method just after it redraws the list? Any Idea?
Since when Android “redraws the list”, it calls
getChildView()on yourExpandableListAdapter, you need to put your highlighting code ingetChildView().