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
151
votes
22 answers

Detect when RecyclerView reaches the bottom most position while scrolling

I have this code for a RecyclerView. recyclerView = (RecyclerView)rootview.findViewById(R.id.fabric_recyclerView); recyclerView.setLayoutManager(layoutManager); recyclerView.addItemDecoration(new RV_Item_Spacing(5)); FabricAdapter fabricAdapter=new…
Adrian
  • 1,677
  • 2
  • 12
  • 12
151
votes
22 answers

RecyclerView blinking after notifyDatasetChanged()

I have a RecyclerView which loads some data from API, includes an image url and some data, and I use networkImageView to lazy load image. @Override public void onResponse(List response) { mItems.clear(); for (Item item : response) { …
Ali
  • 9,800
  • 19
  • 72
  • 152
150
votes
8 answers

Recycler view showing single item

I am facing a strange error where recyclerview is showing only a single item. Below is code for my recyclerview adapter : public class ChatAdapter extends RecyclerView.Adapter { List chats; String username; final int…
Rujul1993
  • 1,631
  • 2
  • 10
  • 10
146
votes
13 answers

How to update/refresh specific item in RecyclerView

I'm trying to refresh specific item in RecyclerView. Story: Whenever user clicks on item, it shows AlertDialog. User can type some text by clicking ok button. I want to show this text in this item and show invisible ImageView - declared in XML and…
Ahmed Elgendy
  • 1,670
  • 2
  • 12
  • 17
145
votes
2 answers

How to add a simple 8dp header/footer to Android's RecyclerView?

Is there a way to add a simple header/footer to a RecyclerView? Here you can see what I've got. The first Card touches the Toolbar And here you can see what I would like to achieve: 8dp Padding between the bottom and the Card. Methods I tried…
Philipp Schumann
  • 1,790
  • 2
  • 12
  • 12
141
votes
13 answers

Recycler view inside NestedScrollView causes scroll to start in the middle

I am getting a weird scrolling behavior when I add a RecyclerView inside a NestedScrollView. What happens is that whenever the scrollview has more rows than can be shown in the screen, as soon as the activity is launched, the NestedScrollView starts…
140
votes
14 answers

Android 5.0 - Add header/footer to a RecyclerView

I spent a moment trying to figure out a way to add a header to a RecyclerView, unsuccessfully. This is what I got so far: @Override protected void onCreate(Bundle savedInstanceState) { ... layouManager = new…
MathieuMaree
  • 7,453
  • 6
  • 26
  • 31
138
votes
24 answers

Android RecyclerView : notifyDataSetChanged() IllegalStateException

I'm trying to update the items of a recycleview using notifyDataSetChanged(). This is my onBindViewHolder() method in the recycleview adapter. @Override public void onBindViewHolder(ViewHolder viewHolder, int position) { //checkbox view…
Arthur
  • 3,636
  • 5
  • 19
  • 25
136
votes
6 answers

Adding Ripple Effect to RecyclerView item

I am trying to add Ripple Effect to RecyclerView's item. I had a look online, but could not find what I need. I assume it has to be a custom effect. I have tried android:background attribute to the RecyclerView itself and set it to…
Georgi Koemdzhiev
  • 11,421
  • 18
  • 62
  • 126
134
votes
20 answers

How to save RecyclerView's scroll position using RecyclerView.State?

I have a question about Android's RecyclerView.State. I am using a RecyclerView, how could I use and bind it with RecyclerView.State? My purpose is to save the RecyclerView's scroll position.
陈文涛
  • 1,343
  • 2
  • 9
  • 5
132
votes
27 answers

CheckBox in RecyclerView keeps on checking different items

Here's the XML for my items inside the RecyclerView
imin
  • 4,504
  • 13
  • 56
  • 103
132
votes
10 answers

CardView layout_width="match_parent" does not match parent RecyclerView width

I have a fragment with contains a RecyclerView with layout_width="match_parent":
130
votes
3 answers

Add a new item to recyclerview programmatically?

I'm still trying to get my head around recyclerview. I have an arraylist, that I use to initialize a recycler view with. How can I add new items to the recycler view post setting an adapter and layoutmanager? private void initData() { …
Shubham Kanodia
  • 6,036
  • 3
  • 32
  • 46
130
votes
12 answers

Using the recyclerview with a database

Currently there is no default implementation of RecyclerView.Adapter available. May be with the official release, Google will add it. Since there is no support for CursorAdapter with the RecyclerView currently, how can we use a RecyclerView with a…
LostPuppy
  • 2,471
  • 4
  • 23
  • 34
129
votes
17 answers

Refreshing data in RecyclerView and keeping its scroll position

How does one refresh the data displayed in RecyclerView (calling notifyDataSetChanged on its adapter) and make sure that the scroll position is reset to exactly where it was? In case of good ol' ListView all it takes is retrieving getChildAt(0),…
Konrad Morawski
  • 8,307
  • 7
  • 53
  • 91