我使用ExpandableRecyclerView创建了列表,但是我想在位置4的此列表中添加第二个子节点。如何在同一列表中添加不同的子节点?
private Activity activity;
public RecyclerAdapterDemo(Activity activity, List<? extends ExpandableGroup> groups) {
super(groups);
this.activity = activity;
}
@Override
public OSViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.group_view_holder, parent, false);
return new OSViewHolder(view);
}
@Override
public PhoneViewHolder onCreateChildViewHolder(ViewGroup parent, final int viewType) {
LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.child_view_holder, parent, false);
return new PhoneViewHolder(view);
}
@Override
public void onBindChildViewHolder(PhoneViewHolder holder, int flatPosition, ExpandableGroup group, int childIndex) {
final Phone phone = ((MobileOS)group).getItems().get(childIndex);
holder.onBind(phone,group);
}
@Override
public void onBindGroupViewHolder(OSViewHolder holder, int flatPosition, ExpandableGroup group) {
holder.setGroupName(group);
}