Array Of Array List In Android To Get The Firebase Object Of Object
I want to calculate the average of each dish by their ratings and display in a bar graph, therefore I need the values of each dish with each thier rating Example 3 people rated mil
Solution 1:
When using the stringArrayList
outside the callback, it will always be empty due the asynchronous behaviour of the onDataChange()
method. If you want to use the stringArrayList
, you should use it only inside the callback. So to solve this, please move the second for loop inside the onDataChange()
method right after the first for loop ends.
If you need to use that list outside the callback, I recommend you see the last part of my anwser from this post in which I have explained how it can be done using a custom callback. You can also take a look at this video for a better understanding.
Post a Comment for "Array Of Array List In Android To Get The Firebase Object Of Object"