I am trying to maintain the scroll position of a ListView that is populated from a FirebaseListAdapter.
I have tried this stackoverflow thread but that's not to say a modification for FirebaseListAdapters may work.
private void displayChatMessages() {
adapter = new FirebaseListAdapter<ChatMessage>(this, ChatMessage.class,
R.layout.messages, FirebaseDatabase.getInstance().getReference()) {
@Override
protected void populateView(View v, ChatMessage model, int position) {
// Get references to the views of message.xml
TextView messageText = (TextView)v.findViewById(R.id.message_text);
TextView messageUser = (TextView)v.findViewById(R.id.message_user);
TextView messageTime = (TextView)v.findViewById(R.id.message_time);
// Set their text
messageText.setText(model.getMessageText());
messageUser.setText(model.getMessageUser());
// Format the date before showing it
messageTime.setText(DateFormat.format("dd-MM-yyyy (HH:mm)",
model.getMessageTime()));
}
};
I should also note that I was unable to reference the method onViewCreated() , which one of the solutions in the aforementioned thread suggested using.