Questions tagged [android-viewholder]

A ViewHolder object stores each of the component views inside the tag field of the Layout, so you can immediately access them without the need to look them up repeatedly. The ViewHolder pattern is often used in Android applications to improve performances of view access.

A ViewHolder object stores each of the component views inside the tag field of the Layout, so you can immediately access them without the need to look them up repeatedly. The ViewHolder pattern is often used in Android applications to improve performances of view access.

For an example, check the official Android documentation on the ViewHolder pattern.

1064 questions
7
votes
3 answers

GapWorker with Scrapped or attached views may not be recycled. isScrap:false isAttached:true

When i scroll my recyclerview too fast i am getting the following crash java.lang.IllegalArgumentException: Scrapped or attached views may not be recycled. isScrap:false isAttached:true …
Reprator
  • 2,859
  • 2
  • 32
  • 55
7
votes
0 answers

Maintain scroll position in nested RecyclerViews

I have a ViewHolder that contains another RecyclerView. This type of the ViewHolder gets reused multiple times. Since the ViewHolder is shared between different items, the scroll position of the RecyclerView is also shared between items. Eg, You…
7
votes
4 answers

Add click listener to Generic RecyclerView Adapter

Edit As It is a genericAdapter not simple one and I know the methods to add click listener. And it is not a good practice to do this in onCreateViewHolder. So that's why I need a better suggestion I have created a Generic Adapter for RecyclerView…
Zar E Ahmer
  • 33,936
  • 20
  • 234
  • 300
7
votes
0 answers

Get Clicked View and position from nested RecyclerView

I'm trying to display meesages in recyclerview. Message 1 attachment-1 attachment-2 Message-2 attachement-1 Messge-3(without attachemnts) I'm creating a new Recyclerview if row has an attachments.The click listener isn't working for the…
7
votes
5 answers

Android listview using ViewHolder

I have a problem. I'm attempting to change an icon in my listview after it has been clicked. It works correctly although are not modified only the clicked icons but also those who are not displayed. For example if I click the icon in the first item…
6
votes
1 answer

Is there a way to find item and scroll to that viewholder using PagingDataAdapter?

I'm using Android Paging Library 3. Is there a way to find item and scroll to that viewholder using PagingDataAdapter? As I'm not able to access the item list. Or I have no choice but have to use normal list adapter?
6
votes
0 answers

RecyclerView: The specified child already has a parent. You must call removeView() on the child's parent first

I have a RecyclerView where I'm getting the exception below. I've only gotten the exception on Crashlytics, I've never managed to reproduce the issue myself despite using that activity heavily every day. The way I inflate my view on…
casolorz
  • 8,486
  • 19
  • 93
  • 200
6
votes
3 answers

getActivity() / context in a ViewHolder in Kotlin Android

I'm building a ViewHolder and Adapter for a Fragment and when I try to make an OnClick for the ViewHolder, none of the contexts I pass in work. There is no activity from getActivity() that I can use, and p0!!.context nor itemView.context work…
6
votes
0 answers

Android - Recycler View Focuses Wrong Holder on EditText click

I have a Recycler View to show a list of data and have edit text inside of Recycler View to allow user edit some number. My app also resizing activity when the keyboard is shown/hidden. The app works great unless I want to edit items which are…
Mohamed
  • 1,251
  • 3
  • 15
  • 36
6
votes
2 answers

How to use setRowViewSelected of ListRowPresenter

I am using default project for Android TV. Following is the code for creating cards in my BrowseFragment: private void loadRows() { List list = MovieList.setupMovies(); ListRowPresenter mListRowPresenter = new ListRowPresenter(); …
Uniruddh
  • 4,427
  • 3
  • 52
  • 86
6
votes
0 answers

View in viewholder does not update (doesn't take height)

I have a viewholder that is configured to wrap_content. In that viewholder I show a view if the user is not logged in. This view is inflated as ViewStub. In the first cells on the screen everything is fine. But if I scroll to the cell that is…
Robin Bruneel
  • 1,063
  • 8
  • 22
6
votes
2 answers

How to reuse RecyclerView objects, adapters and view holders

I have a series of, what used to be called listViews, within my app that are now RecyclerViews. I am curious as to the most efficient way to raise the modularity and reduce repetition of this section of my app. For example, I have the…
Sauron
  • 6,399
  • 14
  • 71
  • 136
6
votes
1 answer

Android RecyclerView - animate item elevation on touch

I would like to achieve a transition like the one shown in this video (from a Google course): https://youtu.be/iYN5mM0JN9M?t=22s In words: when an item of a RecyclerView is clicked, it "comes out" of the list (elevation change) and then expands into…
6
votes
1 answer

Is there a way to use a ViewStub inside a RecyclerView?

i'm new to android, I've been working on a project, and in my news feeds page, I'm trying to include a modular feed RecyclerView, which shows a question with different answer forms, varrying according to the Question type. The way I was doing it so…
6
votes
0 answers

Is RecyclerView.hasStableIds(true) grouped by itemViewType?

I have a RecyclerView with an RecyclerView.Adapter whose backing data is coming from a Cursor via a Loader. The data contains two types of items: A and B returned via an UNION ALL. getItemViewType returns different ints for each (see note below).…
TWiStErRob
  • 44,762
  • 26
  • 170
  • 254