如何在List中动态添加多个数组列表

时间:2017-04-13 07:32:45

标签: android list listview arraylist android-custom-view

我想在列表中添加多个array-list,并使用带有section的自定义适配器在list-view中显示。我试过这里是我试过的代码

chuncks = pd.read_csv(file, header=None, chunksize=100000)

for chunk_number, data in enumerate(chunks):
    y = np.array(data.iloc[:,0], np.float32)
    x = np.array(data.iloc[:,1:], np.float32)

    file_w = open(filename, 'w')
    with h5py.File(modelname + str(idx) + '.h5', 'w') as f:
        f['data'] = x
        f['label'] = y
        file_w.write(modelname + str(chunk_number) + '.h5\n')
    file_w.close()

但它没有显示出预期的结果 任何建议或需要帮助

1 个答案:

答案 0 :(得分:0)

你想要的是一份清单!

List<List<Integer>> lists = new ArrayList<List<Integer>>();
for (int i = 0; i < 4; i++) {
    List<Integer> list = new ArrayList<>();
    lists.add(list);
    // Use the list further...
}

将3个arraylist合并为一个

List<String> combined = new ArrayList<String>();
combined.addAll(firstArrayList);
combined.addAll(secondArrayList);
combined.addAll(thirdArrayList);

参考: - https://stackoverflow.com/a/8625256/7795876