简体   繁体   中英

How do I create a leaderboard from the stats in my Firebase Realtime Database?

I want to create a leaderboard in my app. The leaderboard should show the 10 best users who have the most high scores. My Firebase database looks like this:

Starting with the first TextView I want to change the text to:

To get the top 10 users with the highest score, you can use a query like this:

DatabaseReference usersRef = FirebaseDatabase.getInstance().getReference("Users");
Query top10Query = usersRef.orderByChild("highscore").limitToLast(10);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM