Reputation: 19
I have retrieved data from Firebase regarding name and score. I am being able to see the list view for first name and scores of the data retrieved but for the second data retrieved i can not see no scores or names. When I have debugged the app, I have received this "com.example.gymtastic.SquatScore (fields/setters are case sensitive!)".
private ListView listView, listview2;
DatabaseReference databaseReference;
DatabaseReference ddatabase;
private FirebaseDatabase firebaseDatabase;
List<ScoreProfile> scoreList;
List<SquatScore> squatList;
@Override
protected void onStart() {
super.onStart();
ddatabase.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for(DataSnapshot squatsnapshot : dataSnapshot.getChildren()){
SquatScore squatScore = squatsnapshot.getValue(SquatScore.class);
squatList.add(squatScore);
}
SquatInfoAddapter squatInfoAddapter =new SquatInfoAddapter(RankT.this, squatList);
listview2.setAdapter(squatInfoAddapter);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
throw databaseError.toException();
}
}); // This one doesnt
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rank_t);
firebaseDatabase = FirebaseDatabase.getInstance();
databaseReference = firebaseDatabase.getReference("Bench");
ddatabase = firebaseDatabase.getReference("Squat");
databaseReference.orderByChild("userScore").limitToFirst(5);
ddatabase.orderByChild("userScore").limitToFirst(5);
squatList = new ArrayList<>();
scoreList = new ArrayList<>();
firebaseAuth = FirebaseAuth.getInstance();
This is my code. The first value listener displays but for the second one created, it just shows empty list views.
This is my Firebase data that i am retrieving but does not show.
"Squat" : {
"Jn8SOKDgGRMewEHjVG8LaXoYtrl2" : {
"suserName" : "ace",
"suserScore" : "369"
},
"mooFelp2soMtDmRlg5IQ6AYpKhO2" : {
"suserName" : "ACe",
"suserScore" : "1222"
}
Here is my SquatScore class:
public class SquatScore {
private String SuserName;
private String SuserScore;
public SquatScore(){};
public SquatScore(String suserName, String suserScore) {
SuserName = suserName;
SuserScore = suserScore;
}
public String getSuserName() {
return SuserName;
}
public String getSuserScore() {
return SuserScore;
}
}
Upvotes: 0
Views: 938
Reputation: 600006
The error you get is:
W/ClassMapper: No setter/field for suserName found on class com.example.gymtastic.SquatScore (fields/setters are case sensitive!)"
If we look at your class that is correct:
suserName
, only SuserName
with an uppercase S
.userName
, which would be called setSusername
.Without those, the Firebase SDK has no way to know how to set the value from the suserName
property in the JSON on to your SquatScore
object.
To fix this, you'll want to either rename the field to suserName
, or create the setter method.
Upvotes: 1