假设我有两个模型类。
class School {
ArrayList<Students> students;
public ArrayList<Students> getStudents() {
return students;
}
}
class Students {
String studentName;
public String getStudent() {
return studentName;
}
}
我如何通过检索学生?我试过这个,但它不起作用。
mRef.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
School s1 = datasnapshot.getValue(School.class)
s1.getStudents();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});