Skip to content Skip to sidebar Skip to footer

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.

Solution 2:

I got the solution instead of using Array list of Array List I can create genericTypeIndicator follow this link for the solution

https://stackoverflow.com/a/41503903/5867698

Post a Comment for "Array Of Array List In Android To Get The Firebase Object Of Object"