Questions tagged [android-recyclerview]

The RecyclerView widget is a more advanced and flexible version of ListView and GridView.

The RecyclerView widget is a more advanced and flexible version of ListView and GridView. This widget is a container for displaying large datasets that can be scrolled very efficiently by maintaining a limited number of views. Use the RecyclerView widget when you have data collections whose elements change at runtime based on user action or network events.

• See how to create a list with RecyclerView.


RecyclerApdater Adapter optimized for RecyclerView

The RecyclerView class simplifies the display and handling of large data sets by providing:

  1. Layout Managers for positioning items
  2. Default animations for common item operations, such as removal or addition of items

enter image description here

Tag Usage:

29237 questions
323
votes
12 answers

Get visible items in RecyclerView

I need to know which elements are currently displayed in my RecyclerView. There is no equivalent to the OnScrollListener.onScroll(...) method on ListViews. I tried to work with View.getGlobalVisibleRect(...), but that hack is too ugly and does not…
rekire
  • 47,260
  • 30
  • 167
  • 264
320
votes
33 answers

Android Recyclerview GridLayoutManager column spacing

How do you set the column spacing with a RecyclerView using a GridLayoutManager? Setting the margin/padding inside my layout has no effect.
Nick H
  • 8,897
  • 9
  • 41
  • 64
317
votes
33 answers

How to disable RecyclerView scrolling?

I cannot disable scrolling in the RecyclerView. I tried calling rv.setEnabled(false) but I can still scroll. How can I disable scrolling?
Zsolt Safrany
  • 13,290
  • 6
  • 50
  • 62
308
votes
8 answers

Simple Android grid example using RecyclerView with GridLayoutManager (like the old GridView)

I know that RecyclerView has replaced the functionality of the old ListView and GridView. I am looking for a very basic example that shows a minimal grid setup using RecyclerView. I am not looking for long tutorial style explanations, just a minimal…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
308
votes
15 answers

How to show an empty view with a RecyclerView?

I am used to put an special view inside the layout file as described in the ListActivity documentation to be displayed when there is no data. This view has the id "android:id/empty".
JJD
  • 50,076
  • 60
  • 203
  • 339
303
votes
11 answers

How to animate RecyclerView items when they appear

How can I animate the RecyclerView Items when there are appearing? The default item animator only animates when a data is added or removed after the recycler data has been set. How can this be achieved?
PaulNunezM
  • 3,217
  • 3
  • 14
  • 10
271
votes
19 answers

Scroll RecyclerView to show selected item on top

I'm looking for a way to scroll a RecyclerView to show the selected item on top. In a ListView I was able to do that by using scrollTo(x,y) and getting the top of the element that need to be centered. Something like: @Override public void…
Distwo
  • 11,569
  • 8
  • 42
  • 65
262
votes
25 answers

How can a divider line be added in an Android RecyclerView?

I am developing an android application where I am using RecyclerView. I need to add a divider in RecyclerView. I tried to add - recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), …
sofquestion 8
  • 2,649
  • 2
  • 11
  • 4
259
votes
13 answers

Simple Android RecyclerView example

I've made a list of items a few times using Android's RecyclerView, but it is a rather complicated process. Going through one of the numerous tutorials online works (this, this, and this are good), but I am looking a bare bones example that I can…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
248
votes
27 answers

How to use RecyclerView inside NestedScrollView?

How to use RecyclerView inside NestedScrollView? RecyclerView content is not visible after setting adapter. UPDATE layout code updated.
Mecid
  • 4,491
  • 6
  • 30
  • 30
241
votes
5 answers

Should we use RecyclerView to replace ListView?

Android Docs say: The RecyclerView widget is a more advanced and flexible version of ListView. This widget is a container for displaying large data sets that can be scrolled very efficiently by maintaining a limited number of views. Use the…
Xcihnegn
  • 11,579
  • 10
  • 33
  • 33
217
votes
7 answers

How to set RecyclerView app:layoutManager="" from XML?

How to set RecyclerView layoutManager from XML?
Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216
208
votes
37 answers

Recyclerview not call onCreateViewHolder

My RecyclerView does not call onCreateViewHolder, onBindViewHolder even MenuViewHolder constructor, therefore nothing appears in RecyclerView. I put logs for debugging, and no log is shown. What might be the problem? My adapter: public class…
Malinosqui
  • 2,222
  • 2
  • 13
  • 11
207
votes
13 answers

How to get a context in a recycler view adapter

I'm trying to use picasso library to be able to load url to imageView, but I'm not able to get the context to use the picasso library correctly. public class FeedAdapter extends RecyclerView.Adapter { private List
Stranger B.
  • 9,004
  • 21
  • 71
  • 108
200
votes
20 answers

How do I make WRAP_CONTENT work on a RecyclerView

I have a DialogFragment that contains a RecyclerView (a list of cards). Within this RecyclerView are one or more CardViews that can have any height. I want to give this DialogFragment the correct height based on the CardViews that are contained…