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
72
votes
12 answers

RecyclerView that does not scroll and shows all items

I have a RecyclerView (and some other views) in a ScrollView. Currently the RecyclerView is laid out as very small (it shows 2 items out of 5 that it contains) and it scrolls independently of the ScrollView, which is obviously not great UX. I would…
pstobiecki
  • 1,804
  • 1
  • 17
  • 30
72
votes
3 answers

What is lifecycle for RecyclerView adapter?

I'm requesting images from presenter in adapter: @Override public void onBindViewHolder(SiteAdapter.ViewHolder holder, int position) { Site site = sites.get(position); holder.siteName.setText(site.getName()); …
Eugen Martynov
  • 19,888
  • 10
  • 61
  • 114
72
votes
4 answers

What is the SortedList working with RecyclerView.Adapter?

Android Support Library 22.1 was released yesterday. Many new features were added into the v4 support library and v7, among which android.support.v7.util.SortedList draws my attention. It's said that, SortedList is a new data structure, works…
SilentKnight
  • 13,761
  • 19
  • 49
  • 78
72
votes
24 answers

RecyclerView not calling onCreateViewHolder or onBindView

Not getting any errors and all the data seems valid. For some reason, nether of the view related methods are being called. I have made sure of the following: getItemCount() is the only adapter method being called and is returning a positive integer…
Conti
  • 1,017
  • 1
  • 11
  • 15
71
votes
6 answers

Set drawable for DividerItemDecoration

I'm trying to set my custom drawable (line) for DividerItemDecoration, but with no success. Where is the mistake? DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(getContext(), …
user3352926
  • 1,017
  • 1
  • 10
  • 15
71
votes
4 answers

How to center RecyclerView items horizontally with vertical GridLayoutManager

I have a vertical RecyclerView using a GridLayoutManager. I want each column to be centered, but the columns begin all the way on the left. In the following picture you can see what I'm talking about. I used the ugly color scheme to illustrate the…
JackTheCripple
  • 783
  • 1
  • 5
  • 8
71
votes
8 answers

How to count RecyclerView items with Espresso

Using Espresso and Hamcrest, How can I count items number available in a recyclerView? Exemple: I would like check if 5 items are displaying in a specific RecyclerView (scrolling if necessary).
Boris S.
  • 1,068
  • 1
  • 8
  • 18
71
votes
8 answers

How can I control the scrolling speed of recyclerView.smoothScrollToPosition(position)?

I have a recycler view, and I want a smooth scrolldown and then scrollup to it programatically to show the complete content in it to user. I can do this by: final int height=recyclerView.getChildAt(0).getHeight(); …
Dipika
  • 1,097
  • 1
  • 9
  • 19
70
votes
3 answers

How to add a recyclerView inside another recyclerView

I'm planning to develop an app that shows some dynamic data inside a recyclerCardView. So i decided add a recyclerView called CheckBoxRecyclerView inside my main recyclerView. This is my code for my app : My Main Activity…
Mohammad Fatemi
  • 1,278
  • 2
  • 12
  • 16
70
votes
7 answers

Android Layout: Horizontal Recyclerview inside a Vertical Recyclerview inside a Viewpager with Scroll Behaviors

This is the app I'm trying to build with all the elements mapped out below: Everything works, however, I want the inner horizontal recyclerview not to capture any of the vertical scrolls. All vertical scrolls must go towards the outer vertical…
70
votes
9 answers

Changing number of columns with GridLayoutManager and RecyclerView

Inside my fragment I'm setting my GridLayout in the following way: mRecycler.setLayoutManager(new GridLayoutManager(rootView.getContext(), 2)); So, I just want to change that 2 for a 4 when the user rotates the phone/tablet. I've read about…
69
votes
8 answers

Create Options Menu for RecyclerView-Item

How do I create an Options Menu like in the following Screenshot: The Options Menu should be opened afther clicking on the "More"-Icon of a RecyclerView Item! My try was this: @Override public void onBindViewHolder(Holder holder, int position) { …
the_dani
  • 2,466
  • 2
  • 20
  • 46
69
votes
2 answers

RecyclerView does not Recycling Views when use it inside NestedScrollView

I'm using RecyclerView inside NestedScrollView. Also i set setNestedScrollingEnabled to false for recyclerview to support lower API ViewCompat.setNestedScrollingEnabled(mRecyclerView, false); Now! When user scrolled the view every thing seems okay,…
MAY3AM
  • 1,182
  • 3
  • 17
  • 42
69
votes
9 answers

Detect start scroll and end scroll in recyclerview

I need to detect the start/end and direction of scroll in a recyclerview. The scroll listener has two methods: onScrolled() and onScrollStateChanged(). The first method is called after the scroll is started (indeed is called onScrolled() and not…
greywolf82
  • 21,813
  • 18
  • 54
  • 108
68
votes
9 answers

attr/colorError not found error when using com.android.support:recyclerview-v7:26.0.0-beta2

I'm using Android Studio 3.0 Canary 4. I imported the recycler view library. Then it comes out the attr/colorError not found message. This is app build.gradle: apply plugin: 'com.android.application' android { compileSdkVersion 25 …
Robin
  • 1,487
  • 4
  • 17
  • 29