简体   繁体   中英

How to get the number of children for a specific value in firebase database android?

I am creating an app for android. I would like to get the number of children for a specific value in the firebase database. Then after the user clicks on a button, it will take that data convert it to a percentage, and display it in a textview. I can get the amount of children for each value and printing it to the monitor but when I use the same code and put it in a textview it prints out the last line, not all of it. So my question is how can I get the number of children for a specific value and have it be "compatible" with a textview.

datasnapshot.getChildrenCount()方法返回将在添加到数据库引用的观察器中获得的计数。

Are you referring to getChildrenCount() ? It returns the number of immediate children in your reference. The return type is long so it will be easily manipulate the value, or display it on your textView.

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