How can i make the text appear only a single time in the TextView when retrieving it from Firebase Database

时间:2018-02-03 08:24:50

标签: java android firebase-realtime-database

Here I have used addChildEventListener() method fetch the information from Firebase database under the method onChildAdded().

enter image description here

Please ignore hold.add(chat); as I was just getting the new child's items in an ArrayList. chat is an object of class helper which consists of the name and message of a person.

But the problem that I am facing is that when I am appending the text I am recieving the data using (chat.name+"\n"+chat.message+"\n\n) in a TextView it gets repeated.

enter image description here

i.e I want it to be like

Arunav hi

Arunav wssup bud

Instead of :

Arunav hi

Arunav wssup bud

Arunav hi

Arunav wssup bud

The messages get repeated each time I press the send button of my app.

Thanks in Advance for helping,please forgive me if my question sounds dumb(its my first question on StackOverFlow and also I have very basic knowledge about Firebase Databases. I strongly look forward for help.

AGAIN THANKS.

0 个答案:

没有答案