Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
148 views
in Technique[技术] by (71.8m points)

android - How to fully replace listView/GridView with RecyclerView?

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?

question from:https://stackoverflow.com/questions/26456144/how-to-fully-replace-listview-gridview-with-recyclerview

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...