I have the code:
listView = (ListView) findViewById(R.id.list);
list = new ArrayList<String>();
arrayAdapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, list);
leaderBoard();
}
FirebaseAuth auth = FirebaseAuth.getInstance();
public void leaderBoard(){
database.getReference().child("db/auth/user/").addValueEventListener(new ValueEventListener() {
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
list = new ArrayList<String>();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
System.out.println("The score is: " + snapshot.child("score").getValue());
String s = snapshot.child("name").getValue() + " " + snapshot.child("score").getValue();
list.add(s);
arrayAdapter = new ArrayAdapter(getApplicationContext(), android.R.layout.simple_list_item_1, list);
listView.setAdapter(arrayAdapter);
}
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
// Getting Post failed, log a message
Log.w(TAG, "loadPost:onCancelled", databaseError.toException());
}
});
My goal is to show a list with the users' names and score, so far so good, as shown in the photo.
But now I need the list to show users and points in increasing order based on the score. Can someone help me?