I am making an Android chat application that uses Google firebase to store messages that users write to each other. To display these messages for users, I read them from the database and organized them into a custom ListView using the ListAdapter. This worked fine until I updated my dependencies, specifically firebase ui, so that:
com.firebaseui:firebase-ui:3.1.0
Now the code for creating the list adapter does not work:
adapter = new FirebaseListAdapter<ChatMessage>(FirebaseDatabase.getInstance().getReference("Lobbies").child(leaderID).child("Messages"), ChatMessage.class, R.layout.message, this) { @Override protected void populateView(View v, ChatMessage model, int position) {
To fix this problem, I updated the code to meet the new requirements of firebase ui, making the code as follows:
FirebaseListOptions<ChatMessage> options = new FirebaseListOptions.Builder<ChatMessage>() .setQuery(FirebaseDatabase.getInstance().getReference("Lobbies").child(leaderID).child("Messages"), ChatMessage.class).setLayout(R.layout.message).build(); adapter = new FirebaseListAdapter<ChatMessage>(options) { @Override protected void populateView(View v, ChatMessage model, int position) {
This code now compiles, but the list does not display data. Is there a specific correct way to use the new firebase ui dependency to create a list adapter?
java android firebase firebase-database firebaseui
Dylan kane
source share