0

I am a newbie android developer and I am learning now with firebase realtime database. I have a big problem because I want to sort my list from latest to oldest so I would know which one was added recently. Please help me achieve it.

1 Answers1

1

There are few ways to achieve this. If you want to make it sorted when to display only. You can use this. Apply app:reverseLayout = "true" and app:stackFromEnd = "true".

<androidx.recyclerview.widget.RecyclerView
    android:id="@+id/rv_explorer"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
    app:reverseLayout="true"
    app:stackFromEnd="true"
    tools:itemCount="5"
    tools:listitem="@layout/item_explorer" />
Dharman
  • 30,962
  • 25
  • 85
  • 135
Ticherhaz FreePalestine
  • 2,738
  • 4
  • 20
  • 46