Firebaseui-android: listview reverse problem

Created on 2 Mar 2016  Â·  6Comments  Â·  Source: firebase/FirebaseUI-Android

Dear Frank van Puffelen,
Your tutorial is very good thank you very much for this.
But i have a problem, i cant make reverse listview. I want to new message goes to top on the screen.. By the way, please explaine like tutorial because i dont understand.
Please help me, thank you very much again.You are the best!

Most helpful comment

Thank you for the direction @puf.
Apologies for digging up a closed issue, I just wanted to note in order to correctly reverse a recycler view you also need to call setReverseLayout(true) as well as calling setStackFromEnd(true).
e.g:

LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager)

(Ensuring you set both before adding the layout manager to the recycler view also)
Perhaps anyone else stumbling through old stack overflow answers will see this and avoid unnecessarily calling costly queries on their firebase instances like most of the stack overflow answers suggested.

All 6 comments

If you're using a ListView:

listView.setStackFromBottom(true);

For a RecyclerView:

manager.setStackFromEnd(true);

Note that these are basic Android questions, so are better posted (or search for) on StackOverflow.

Thank you for the direction @puf.
Apologies for digging up a closed issue, I just wanted to note in order to correctly reverse a recycler view you also need to call setReverseLayout(true) as well as calling setStackFromEnd(true).
e.g:

LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true);
recyclerView.setLayoutManager(layoutManager)

(Ensuring you set both before adding the layout manager to the recycler view also)
Perhaps anyone else stumbling through old stack overflow answers will see this and avoid unnecessarily calling costly queries on their firebase instances like most of the stack overflow answers suggested.

@ahaverty thanks for the tip about setting the LayoutManager properties before calling setLayoutManager, that's explains some weird non-reproducible issues I've had in the past!

Same here @ahaverty: thanks for excavating. :-)

Feel free to leave comments/edits on the Stack Overflow question too for
those who don't find it here.

On Wed, Jul 6, 2016 at 9:47 AM Sam Stern [email protected] wrote:

@ahaverty https://github.com/ahaverty thanks for the tip about setting
the LayoutManager properties before calling setLayoutManager, that's
explains some weird non-reproducible issues I've had in the past!

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/firebase/FirebaseUI-Android/issues/90#issuecomment-230833503,
or mute the thread
https://github.com/notifications/unsubscribe/AA3w35WI43HdGZQQzdbCF6oCyCr_p9_8ks5qS9wagaJpZM4HnocQ
.

@ahaverty thanks for the explanation. I was struggling to do the reverse ordering in recycler views. This was the best and simpler solution I've found.

@ahaverty setting both

layoutManager.setReverseLayout(true);
layoutManager.setStackFromEnd(true); 

Does the trick for reversing the order of the list, but the user view starts at the bottom of the list instead of the top (needing to scroll-up to see the last item of the list).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hendrep picture hendrep  Â·  3Comments

sbotev5 picture sbotev5  Â·  4Comments

long1eu picture long1eu  Â·  4Comments

pedrodanielcsantos picture pedrodanielcsantos  Â·  4Comments

ghost picture ghost  Â·  5Comments