1 回答

TA貢獻(xiàn)1858條經(jīng)驗 獲得超8個贊
我對 Firestore 不熟悉,但似乎QueryDocumentSnapshot與Map<String, Object>. 以下代碼片段顯示了如何將這些值分別存儲到List代碼中聲明的progressList 和titleList 中。
List<int> progressList = new ArrayList<>();
List<String> titleList = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
progressList.add(Integer.valueOf(document.get("progress").toString()));
titleList.add(document.get("title").toString());
}
如果你仍然想用來Array存儲值,你可以使用 API,ArrayList.toArray()如下所示:
int[] prog = new int[progressList.size()];
prog = progressList.toArray(prog);
String[] title = new String[titleList.size()];
title = titleList.toArray(title);
添加回答
舉報