How to fully replace listView/GridView with RecyclerView?
Asked Answered
G

3

38

I've noticed that the new RecyclerView class, even though it makes things a bit cleaner, is lacking a lot of functionality that I'm familiar with:

  1. dividers, but this can be solved by looking at this post or this one
  2. "footerDividersEnabled"
  3. "headerDividersEnabled"
  4. "listSelector" , but maybe I should simply set it per view ?
  5. "fastScrollEnabled"
  6. "smoothScrollbar"
  7. "textFilterEnabled"
  8. I've also tried to find out if there is a new way to use the new class with filtering (as done with ListView by implementing Filterable). I couldn't find out if there is such a thing
  9. "tools:listitem" , to show the items on the UI designer.

Those are what I use, but maybe there are others that I missed.

Is there any tutorial or some guidelines of how to replace each of those things?

Gus answered 19/10, 2014 at 22:33 Comment(3)
I agree with missing capabilities. We now have to bridge this gap to add these features to the RecyclerView. More work for us, but ultimately a faster running program. Personally, I have decided to stick with the ListView in the mean time while people and Google will work out the kinks.Freedafreedman
@Binghammer Well this is about the same decision I've made when they released GridLayout. I've tried to play with it, decided that it's not enough, and went back to the usual layouts instead...Gus
Solutions in the thread Should we use RecyclerView to replace ListView?Hypnotic
G
9

ok, I think I've found some solutions to what I wrote about:

  1. dividers - the links I've given can probably help (here, here and here).
  2. "footerDividersEnabled" - probably like #1, but even if you don't have it, you could always add a divider to the layout of the footer.
  3. "headerDividersEnabled" - same as #2.
  4. "listSelector" - should be done to the item views .
  5. "fastScrollEnabled" - no solution is available for this, except for this library I've found, which was an answer for my post here.
  6. "smoothScrollbar" - should be a feature request for #5. I think it's already smooth, but I'm not sure.
  7. "textFilterEnabled" - sadly, you need to handle it yourself. create a thread pool of size 1, or manage your own thread (or use AsyncTask, in case the work is relatively short), and let it do the filtering for you.
  8. Filterable - same as #7
  9. "tools:listitem" - not available, but I think you could extend from RecyclerView and add it. You will however have to put some work, as RecyclerView doesn't know how to layout the views.
Gus answered 28/2, 2015 at 15:23 Comment(0)
S
0

No tutorials that I know of, but the sources for ListView are public! There's no better way to learn than this... For example: I recently implemented filtering just like ListView does and it work like a charm. Plus, if you do it well, you only need to do it once and can re-apply it everywhere!

Stoss answered 27/12, 2014 at 21:39 Comment(0)
T
0

I would recommend you go look at some of the library's for the RecyclerView. You can find a lot of library's at https://android-arsenal.com/.

Also you can implement your own functionality in the RecyclerView and the Adapter for the RecyclerView. Just extend the RecyclerView and build on that.

I recommend that you read the source code for the RecyclerView at https://android.googlesource.com/platform/frameworks/support/+/refs/heads/master/v7/recyclerview/src/android/support/v7/widget/RecyclerView.java.

Time answered 28/1, 2015 at 14:43 Comment(1)
I've already managed to work on it, but a lot of those functionalities are still missing. The one that I miss the most (and still can't solve) is "fastScrollEnabled", and for this I've even made a new post: https://mcmap.net/q/265172/-how-to-add-a-fast-scroller-to-the-recyclerview/878126 . The rest is just annoying to add/ignore .Gus

© 2022 - 2024 — McMap. All rights reserved.