如何管理从Firestore检索并在适配器中设置的阵列数据?

时间:2019-07-18 18:00:30

标签: android google-cloud-firestore

我想从firestore中获取数据,其中包括一个主题数组列表,并将这些数据放入数组适配器。

 public Findtutorclass(String name, String education, String city,String Email, String subject, String profileImg) {
    Name = name;
    Education = education;
    City = city;
    Subject = subject;
    this.profileImg = profileImg;
    this.Email = Email;
}
db.collection("Tutor")
        .get().addOnCompleteListener( new OnCompleteListener <QuerySnapshot>() {
    @Override
    public void onComplete(@NonNull Task<QuerySnapshot> task) {
        if(task.isSuccessful()){
            for(QueryDocumentSnapshot document : task.getResult()) {
                Findtutorclass p = document.toObject(Findtutorclass.class);
                pojoClassArrayList.add(p);
            }
            recyclerView.setHasFixedSize( true );
            adapterlist = new FindtutorAdapterlist(Find_tutor.this,pojoClassArrayList);
            recyclerView.setAdapter( adapterlist );
        }else{
            Toast.makeText( Find_tutor.this,"not success",Toast.LENGTH_SHORT ).show();
        }

    }
} ).addOnFailureListener( new OnFailureListener() {
    @Override
    public void onFailure(@NonNull Exception e) {
        Toast.makeText( Find_tutor.this,e.getMessage(),Toast.LENGTH_SHORT ).show();
    }
} );

0 个答案:

没有答案