【发布时间】:2018-01-03 20:41:58
【问题描述】:
加载后停止从 Firebase 检索数据。
这是我的代码:
databaseReference.child("SHARE").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot ds : dataSnapshot.getChildren()) {
information spacecraft = ds.getValue(information.class);
spacecrafts.add(spacecraft);
}
adapter adapterView= new adapter(MainActivity.this, spacecrafts);
gridView.setAdapter(adapterView);
}
}
【问题讨论】:
-
您好,欢迎来到 StackOverflow。请花一些时间阅读帮助页面,尤其是名为"What topics can I ask about here?" 和"What types of questions should I avoid asking?" 的部分。更重要的是,请阅读the Stack Overflow question checklist。您可能还想了解Minimal, Complete, and Verifiable Examples。
-
如果您想一次性加载数据而不是实时加载,请添加单值侦听器。希望对你有帮助
标签: java android firebase gridview firebase-realtime-database