Firebase List Adapter Constructor error

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 12:32:38

The below is implied from FirebaseUI version 3.0+

remove this:

   adapter = new FirebaseListAdapter<ChatMessage>(this,ChatMessage.class,R.layout.list_item,FirebaseDatabase.getInstance().getReference())

you need to add this:

FirebaseListOptions<ChatMessage> options =
            new FirebaseListOptions.Builder<ChatMessage>()
                    .setQuery(query, ChatMessage.class)
                     .setLayout(android.R.layout.simple_list_item_1)
                    .build();
 adapter = new FirebaseListAdapter<ChatMessage>(options){

query is the query that you make for the list adapter example:

Query query = FirebaseDatabase.getInstance().getReference().child("chats");

more information here:

Using FirebaseUI to populate a ListView

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!