我正在尝试从Firestore中检索文档。加载文档时如何添加进度条? 这是我的代码:
documentreference.addSnapshotListener(new EventListener<DocumentSnapshot>() {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
String UserId=documentSnapshot.getId();
ProductModel productModel1 = documentSnapshot.toObject(ProductModel.class).withId(UserId);
productModels.add(productModel1);
chatListAdapter.notifyDataSetChanged();
}
});
答案 0 :(得分:1)
在活动开始时显示ProgressBar
,即只需在xml中定义一个ProgressBar
,并确保其在开始时可见。
现在,当所有数据加载完毕后,只需将其删除即可。
documentreference.addSnapshotListener(new EventListener < DocumentSnapshot > () {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
String UserId = documentSnapshot.getId();
ProductModel productModel1 = documentSnapshot.toObject(ProductModel.class).withId(UserId);
productModels.add(productModel1);
chatListAdapter.notifyDataSetChanged();
progressBar.setVisibilty(View.GONE);
}
});
答案 1 :(得分:0)
documentreference.addSnapshotListener(new EventListener < DocumentSnapshot > () {
@Override
public void onEvent(@Nullable DocumentSnapshot documentSnapshot, @Nullable FirebaseFirestoreException e) {
String UserId = documentSnapshot.getId();
ProductModel productModel1 = documentSnapshot.toObject(ProductModel.class).withId(UserId);
productModels.add(productModel1);
chatListAdapter.notifyDataSetChanged();
progressBar.setVisibilty(View.GONE);
}
});