[Solved] Only the last element is shown in Firebase database


What your code doing is just replacing the current text in the TextView with the factdata.getFactDetail().

For example you have 3 elements 1, 2, and 3. Then you want to display the element inside the TextView. With your code, this is what happen

First iteration:

element = elements[0];        // element = 1
factViewBox.setText(element); // TextView text is "1"

Second iteration:

element = elements[1];        // element = 2
factViewBox.setText(element); // TextView text is "2"

Third iteration:

element = elements[2];        // element = 3
factViewBox.setText(element); // TextView text is "3"

Therefore, your TextView only displaying the last element/fact detail

2

solved Only the last element is shown in Firebase database