Answer the question
In order to leave comments, you need to log in
How to fix FirebaseListAdapter cannot be applied?
I did a chat based on a video tutorial, but an error popped up - error: constructor FirebaseListAdapter in class FirebaseListAdapter cannot be applied to given types;
adapter= new FirebaseListAdapter(this, Message.class, R.layout.list_item, FirebaseDatabase.getInstance().getReference()) {
required: FirebaseListOptions
found: MainActivity,Class,int,DatabaseReference
reason: actual and formal argument lists differ in length
where T is a type-variable:
private void displayAllMessages() {
ListView listOfMessages = findViewById(R.id.list_of_messages);
adapter= new FirebaseListAdapter<Message>(this, Message.class, R.layout.list_item, FirebaseDatabase.getInstance().getReference()) {
@Override
protected void populateView(View v, Message model, int position) {
TextView mess_user, mess_time, mess_text;
mess_user = v.findViewById(R.id.message_user);
mess_time = v.findViewById(R.id.message_time);
mess_text = v.findViewById(R.id.message_text);
mess_user.setText(model.getUserName());
mess_text.setText(model.getTextMessage());
mess_time.setText(DateFormat.format("dd-MM-yyyy HH:mm:ss", model.getMessageTime()));
}
};
listOfMessages.setAdapter(adapter);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question