如何将数据分组填充。
将下面的"李健康","张健全"添加到第一组,将"杨无灾","张无难"添加到第二组
private List<BaseNode> getEntity1() {
String [] secondNodeList1 =new String[] {"一组","二组","三组","四组","五组","六组"};
String [][] FirstNode1 = new String[][]{{"李健康","张健全"},{"杨无灾","张无难"},
{"杨定云","陈定雨"},{"曾阿牛","普阿猫"},{"赵贵人","高才人"},
{"何必","任性"}};
List<BaseNode> list = new ArrayList<>();
for (int i = 0; i < secondNodeList1.length; i++) {
List<BaseNode> secondNodeList = new ArrayList<>();
for (int n = 0; n <= FirstNode1[n].length; n++) {
SecondNode seNode = new SecondNode(secondNodeList, ""+FirstNode1[0][0]);
secondNodeList.add(seNode);
}
FirstNode entity = new FirstNode(secondNodeList, secondNodeList1[i]);
list.add(entity);
}
return list;
}
FirstNode 类
public class FirstNode extends BaseExpandNode {
private List<BaseNode> childNode;
private String title;
public FirstNode(List<BaseNode> childNode, String title) {
this.childNode = childNode;
this.title = title;
setExpanded(false);
}
public String getTitle() {
return title;
}
@Nullable
@Override
public List<BaseNode> getChildNode() {
return childNode;
}
}
SecondNode 类
public class SecondNode extends BaseExpandNode {
private List<BaseNode> childNode;
private String title;
public SecondNode(List<BaseNode> childNode, String title) {
this.childNode = childNode;
this.title = title;
setExpanded(false);
}
public String getTitle() {
return title;
}
@Nullable
@Override
public List<BaseNode> getChildNode() {
return childNode;
}
}