Q:

How can I resolve OnSucceslistener on a TabLayout Fragment

This is the Database[][1]
I am trying to populate the layout I made on a tab layout Fragment with data from a Cloud Firestore database and with the following code the error says that:

success listener in Task cannot be applied(addOnSuccessListener
  (com.google.android.gms.tasks.OnSuccessListener)
  in Task cannot be applied
  to
  (anonymous com.google.android.gms.tasks.OnSuccessListener)
   )

This is my code:
@Override
public void onStart(){
    super.onStart();

    notebookRef.get().addOnSuccessListener(new 
        OnSuccessListener<DocumentSnapshot>() {
            @Override
            public void onSuccess(DocumentSnapshot documentSnapshot) {
                if (documentSnapshot.exists()) {
                    Items items = documentSnapshot.toObject(Items.class);

                    String name1 = items.getName();
                    String company1 = items.getCompany();
                    String image1 = items.getImage();

                    name.setText(name1);
                    company.setText(company1);
                    Picasso.get()
                        .load(image1)
                        .fit()
                        .centerCrop()
                        .into(imageView);
                } else {
                    Toast.makeText(getContext(), "Document does not exist", Toast.LENGTH_SHORT).show();
            }
        }
    }).addOnFailureListener(new OnFailureListener() {
           @Override
           public void onFailure(@NonNull Exception e) {
                Log.d(TAG, e.toString());
           }
    });
}

A:

You are getting the following error:

addOnSuccessListener (com.google.android.gms.tasks.OnSuccessListener) in Task cannot be applied to (anonymous com.google.android.gms.tasks.OnSuccessListener)

Because you are using DocumentSnapshot instead of using a QuerySnapshot. To solve this, please use the following lines of code:
FirebaseFirestore rootRef = FirebaseFirestore.getInstance();
CollectionReference phonesRef = rootRef.collection("Phones");
phonesRef.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
    @Override
    public void onComplete(@NonNull Task<QuerySnapshot> task) {
        if (task.isSuccessful()) {
            for (QueryDocumentSnapshot document : task.getResult()) {
                Items items = document.toObject(Items.class);

                String name1 = items.getName();
                String company1 = items.getCompany();
                String image1 = items.getImage();

                name.setText(name1);
                company.setText(company1);
                Picasso.get()
                        .load(image1)
                        .fit()
                        .centerCrop()
                        .into(imageView);
            }
        }
    }
});

Now it will work since we are using QuerySnapshot and not the DocumentSnapshot to get the Item objects.

