Good morning guys,
I need to build a custom adapter using the following nested linked hashmap: LinkedHashMap<String, LinkedHashMap<String, Class<?>>>
. I am extending BaseExpandableListAdapter
and have implemented the methods required. I have written the following code to get the group names from the LinkedHashMap
:
private Context context;
private LinkedHashMap<String, LinkedHashMap<String, Class<?>>> menuOptions;
public customMenuAdapter(Context context, LinkedHashMap<String, LinkedHashMap<String, Class<?>>> menuOptions)
{
this.context = context;
this.menuOptions = menuOptions;
}
@Override
public Object getGroup(int groupPosition)
{
return this.menuOptions.get(groupPosition);
}
@Override
public long getGroupId(int groupPosition)
{
return groupPosition;
}
@Override
public int getGroupCount()
{
return this.menuOptions.size();
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent)
{
String gpsMenuGroupTitle = (String) getGroup(groupPosition);
if (convertView == null) {
LayoutInflater gpsGroupInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = gpsGroupInflater.inflate(R.layout.gps_menu_list_header, null);
}
TextView gpsListHeaderText = (TextView) convertView.findViewById(R.id.gps_menu_list_header);
gpsListHeaderText.setText(gpsMenuGroupTitle);
return convertView;
}
I have to get the child items from the nested LinkedHashMap
and I have no idea how to do so.
In the getChild
method do I simply return this.menuOptions.get(groupPosition).get(childPosition);
? Should I create a field and extract the nested LinkedHashMap
into it?
Any advice would be appreciated!