xxxxxxxxxx
messagesRef.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot snapshot, @Nullable String previousChildName) {
// Handle new message
Message newMessage = snapshot.getValue(Message.class);
// Update UI
}
// Other ChildEventListener methods
});