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
2
votes
1 answer

onCreateViewHolder(ViewGroup parent, int viewType)

In onCreateViewHolder(ViewGroup parent, int viewType) I do not understand the purpose of the parent and viewType parameters. Can anyone explain with an example? In my RecyclerView, I am using an ImageView and a TextView to display an item of the…
sh ra
  • 41
  • 2
2
votes
0 answers

findViewHolderForAdapterPosition() always returns null for custom ViewHolder

So I'm having trouble getting the ViewHolder by adapter position. I'm using the LayoutManager to get the first completely visible item position, but when i call findViewHolderForAdapterPosition() it returns null. I'm also doing a check if postion is…
2
votes
2 answers

Store value to arraylist from json data and populate view holder

I am making an application in which I am receiving some JSON data from url as shown in this Image. Basically every date array has 5 objects in it and I am using this piece of code to get the session from and session to values from each date array …
2
votes
1 answer

change background of all other elements in recyclerview

When a user clicks a cardView in the recyclerView its background changes color to show its selected. What I'm struggling with is that when I select another card I want the previously selected one to go back to "unselected" form. How can I get the…
Cleaven
  • 974
  • 2
  • 9
  • 30
2
votes
1 answer

CountdownTimer inside Recyclerview Adapter is not working properly

I'm creating a horizontal recycler view that scrolls automatically after a certain time (Say 5 seconds). I used countdowntimer. But, it is not working as expected. the timer is not running properly. Some times it jumps two or more recycler items at…
user8215153
2
votes
1 answer

How to access Recyclerview.ViewHolder params from outside of adapter?

I have recyclerview attached to SnapHelper. Then I made scrollListener for recyclerview and everytime the item is snapped to the center of the display, I will find that snapped view, then I will get its viewHolder instance by…
martin1337
  • 2,384
  • 6
  • 38
  • 85
2
votes
1 answer

How do iterate through all the views/items in a RecyclerView?

I need to iterate through all the RadioGroups in my RecyclerView. Code i tried: for(int i=0;i
2
votes
1 answer

Multiple ViewHolder RecycleVIew List rearrange

I tried to find the solution but I think nobody had such a problem. So I have been using ListView in most of my projects and I feel it is more flexible in terms of not having to Bind with ViewHolder as you need to do in RecyclerView. But since I…
Sam
  • 2,935
  • 1
  • 19
  • 26
2
votes
0 answers

firebase data being synced up in viewholder accidentally

I'm working on an app that is using an Expandable List Adapter to vote on certain characteristics of a movie. There's a problem where the viewholders are getting synced up with each other some, but not all of the time. i.e. the holder total and…
2
votes
2 answers

Recyclerview: using multiple viewtypes vs setting visibility for different layouts

I am using recycler view in a chat app, now as you all know in a chat room we have 2 different views. Right view : the one that you sent. Left view : the one that you received. Now I managed to achieve what I want by using one layout item and inside…
Hasan Bou Taam
  • 4,017
  • 2
  • 12
  • 22
2
votes
4 answers

Recyclerview is not displaying data when using generic adapter & viewholder

In my android project, I created Generic RecyclerView's Adapter class & Viewholder class like below, Adapter class, public class BaseRecyclerViewAdapter extends RecyclerView.Adapter { private ItemClickListener…
2
votes
0 answers

Communication in Android between main view and RecyclerViewAdapter with MVVM

I'm trying to architect a screen with a fragment containing a date picker and some basic inputs and a list of items which more inputs. I'll try to exemplify with images: and a screen like this: Input Field 1 and 2 is in ViewModel. The input…
reinaldomoreira
  • 5,388
  • 3
  • 14
  • 29
2
votes
1 answer

Non-visible ViewHolder animation is delayed in RecyclerView

In the ViewHolder of my RecyclerView, I have a method that is called to animate the alpha value of one of its TextViews. The ViewHolders are registered to a global notifier in onBindViewHolder and unregistered in onViewRecycled. When notified, all…
2
votes
1 answer

Is this bug related to Recycler View setup? How can I resolve it?

The screenshot of the emulator is attached below. Initially when the application is run is setup ,the layout gets distorted . Only after scrolling the items get layout properly . It seems as if only after the view has been recycled, the position…
Rambo
  • 93
  • 9
2
votes
3 answers

RecyclerView with checkbox checked/unchecked automatically when I am scrolling

this is my QuestionHolder: private class QuestionHolder extends RecyclerView.ViewHolder implements View.OnClickListener { private JSONObject question; private CheckBox checkBox; private TextView question_txt; public…