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
68
votes
9 answers

How to implement ItemAnimator of RecyclerView to disable the animation of notifyItemChanged

In my project I need disable the "change" animation of RecyclerView while notifyItemChanged. I investigated in the source of RecyclerView and had overridden android.support.v7.widget.DefaultItemAnimator as below: private static class ItemAnimator…
Kenny
  • 1,901
  • 2
  • 11
  • 8
68
votes
7 answers

Android: How to get the current X offset of RecyclerView?

I'm using a Scrollview for an infinite "Time Picker Carousel" and found out, that it is not the best approach (last question) Now, I found the Recycler View but I am unable to get the current scroll offset in X direction of the recyclerView? (Let's…
longi
  • 11,104
  • 10
  • 55
  • 89
67
votes
5 answers

How to get item from RecyclerView adapter in Android

In old code when I was using ListView with custom adapter I could get item with this code. Message msg = (Message) adapter.getItem(poistion); Now I am implementing RecyclerView. How can I get item from RecyclerView.adapter?
Rafael
  • 6,091
  • 5
  • 54
  • 79
67
votes
10 answers

Touch feedback with RecyclerView and CardView

I would love to enable touch feedback for my Open-Source library. I've created a RecyclerView and a CardView. The CardView contains different areas with different onClick actions. Now I would love to trigger the Ripple effect if a user clicks…
66
votes
11 answers

Endless RecyclerView with ProgressBar for pagination

I am using a RecyclerView and fetching objects from an API in batches of ten. For pagination, I use EndlessRecyclerOnScrollListener. It's all working properly. Now all that's left is to add a progress spinner at the bottom of the list while the next…
66
votes
12 answers

Recyclerview not scrolling to end when keyboard opens

I am using recylerview in my application and whenever new element is added to recyclerview, it scrolls to last element by using recyclerView.scrollToPosition(adapter.getCount()); But, whenever keyboard opens(because of editTextView), it resizes the…
66
votes
12 answers

RecyclerView header and footer

Maybe this question has been asked before, but I could not seem to find a precise answer or solution. I started using the RecyclerView, and I implemented it using the LinearLayoutManager. Now I want to add custom header and footer items, that differ…
Sandra
  • 4,239
  • 10
  • 47
  • 80
65
votes
14 answers

Remove all items from RecyclerView

I am trying to remove all the elements from my RecyclerView in my onRestart method so the items don't get loaded twice: @Override protected void onRestart() { super.onRestart(); // first clear the recycler view so items are not populated…
user2456977
  • 3,830
  • 14
  • 48
  • 87
65
votes
3 answers

No good example about RecyclerView and StaggeredGridLayoutManager in Android Docs

I couldn't find any better example for using RecyclerView with StaggeredGridLayoutManager. Not even in Android Docs. Q1. I need some examples which can give proper explanation about how to use RecyclerView with StaggeredGridLayoutManager. Q2. Can…
Amrut Bidri
  • 6,276
  • 6
  • 38
  • 80
65
votes
14 answers

RecyclerView and SwipeRefreshLayout

I'm using the new RecyclerView-Layout in a SwipeRefreshLayout and experienced a strange behaviour. When scrolling the list back to the top sometimes the view on the top gets cut in. If i try to scroll to the top now - the Pull-To-Refresh triggers.…
Lukas Olsen
  • 5,294
  • 7
  • 22
  • 28
64
votes
5 answers

Is there a way to show a preview of a RecyclerView's contents as Grid in the Android Studio editor?

When I add the RecyclerView to the layout, it shows up as a list view in vertical order. I am using tools:listitem for this. Is there a way, such that it displays as grid but not as list in the Android Studio Editor?
Anand Kumar
  • 1,439
  • 1
  • 15
  • 22
64
votes
11 answers

Get center visible item of RecycleView when scrolling

This is what I want: As image above, I want to draw a center line on RecycleView, then get the center item when scrolling (as well as move left or right) Here is my try to draw a horizontal RecycleView: HorizontalAdapter adapter = new…
ductran
  • 10,043
  • 19
  • 82
  • 165
64
votes
26 answers

Inconsistency detected in RecyclerView, How to change contents of RecyclerView while scrolling

I'm using RecyclerView to display name of the items. My row contains single TextView. Item names are stored in List mItemList. To change contents of RecyclerView, I replace Strings in mItemList and call notifyDataSetChanged() on…
jimmy0251
  • 16,293
  • 10
  • 36
  • 39
63
votes
3 answers

What's better? notifyDataSetChanged or notifyItemChanged in loop?

So I have an activity with RecyclerView and I want to change TextView of every item in the RecyclerView by pressing button that has onClickListener() in the activity. I'm wondering what is better in terms of performance: Use notifyDataSetChanged…
Daniel
  • 993
  • 2
  • 10
  • 23
63
votes
4 answers

Is there a callback for when RecyclerView has finished showing its items after I've set it with an adapter?

Background I've made a library that shows a fast-scroller for RecyclerView (here, in case anyone wants), and I want to decide when to show and when to hide the fast-scroller. I think a nice decision would be that if there are items that aren't shown…
android developer
  • 114,585
  • 152
  • 739
  • 1,270