In my project, Expandable list view is common for all logins, but in new update, based on role of login user, i want to stop showing children of certain groupviews. I managed to put an "Access Denied" dialog, but I cannot stop, the expansion of groupview or showing child view. Is there a way for that?
I tried to pass role to the adapter of the expandableListAdapter class and write some cases in getChildView like if (groupPosition==1 && role == 1) I inflated an empty layout. This way I cannot prevent expansion, the child view is still being shown but it is empty and on clicking of that, it is throwing null pointer exception.
I found a way for that, I returned the child count for my specific cases 0
@Override
public int getChildrenCount(int groupPosition) {
Log.e("getChildrenCount", "getChildrenCount");
if ((this.listDataChild.get(this.listDataHeader.get(groupPosition)) == null)
|| (roleId.equalsIgnoreCase("2") && groupPosition!=1)
|| (roleId.equalsIgnoreCase("3") && groupPosition!=2)
|| (roleId.equalsIgnoreCase("5") && groupPosition!=4) )
return 0;
else
return this.listDataChild.get(this.listDataHeader.get(groupPosition)).size();
}
This worked for me Thanks