我创建了一个显示聊天信息的函数,遵循了一个教程,还查看了firebase列表适配器的文档,但无论我做什么,都会出现以下错误:
Error:(98, 19) error: constructor FirebaseListAdapter in class
FirebaseListAdapter<T> cannot be applied to given types;
required: FirebaseListOptions<ChatMessage>
found: Chat,Class<ChatMessage>,int,DatabaseReference
reason: actual and formal argument lists differ in length
where T is a type-variable:
T extends Object declared in class FirebaseListAdapter
这是我的密码:
private void displayChatMessage() {
ListView listOfMessage = (ListView)findViewById(R.id.list_of_messages);
FirebaseRecyclerOptions<ChatMessage> options =
new FirebaseRecyclerOptions.Builder<ChatMessage>()
.setQuery(query, ChatMessage.class)
.build();
adapter = new FirebaseListAdapter<ChatMessage, Holder>(options){
@Override
protected void populateView(View v, ChatMessage model, int position) {
//Get references to the views of list_item.xml
TextView messageText, messageUser, messageTime;
messageText = (TextView) v.findViewById(R.id.message_text);
messageUser = (TextView) v.findViewById(R.id.message_user);
messageTime = (TextView) v.findViewById(R.id.message_time);
messageText.setText(model.getMessageText());
messageUser.setText(model.getMessageUser());
messageTime.setText(DateFormat.format("dd-MM-yyyy (HH:mm:ss)", model.getMessageTime()));
}
};
listOfMessage.setAdapter(adapter);
}
1条答案
按热度按时间nuypyhwy1#
以下是firebaseui 3.0版的隐含内容+
删除此项:
您需要添加以下内容:
Query query = FirebaseDatabase.getInstance().getReference().child("chats");