Решение 1:
Используйте ExpandableListView и в group_child_layout возьмите четыре ImageView (независимо от кнопок).
Назначьте соответствующие данные (например, присвойте телефонному номеру значение call_icon). Пример ниже:
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
ChildHolder childHolder = null;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.item_group_child, parent, false);
childHolder = new ChildHolder();
convertView.setTag(childHolder);
}
else {
childHolder = (ChildHolder) convertView.getTag();
}
/* Assign all the buttons their respective data from ContactData object*/
return convertView;
}
Решение 2:
Используйте ExpandableListView и в group_child_layout возьмите RecyclerView (для горизонтального списка кнопок) в нем. Пример ниже:
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
ChildHolder childHolder = null;
if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.item_group_child, parent, false);
childHolder = new ChildHolder();
convertView.setTag(childHolder);
}
else {
childHolder = (ChildHolder) convertView.getTag();
}
childHolder.horizontalListView = (RecyclerView) convertView.findViewById(R.id.buttons);
LinearLayoutManager layoutManager = new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false);
childHolder.horizontalListView.setLayoutManager(layoutManager);
ButtonsAdapter horizontalListAdapter = new ButtonsAdapter(context, brands.get(groupPosition).buttons);
childHolder.horizontalListView.setAdapter(horizontalListAdapter);
return convertView;
}