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
2 answers

Save state of the item selected in RecyclerView when view is reused while scrolling

I have created an Adapter and ViewHolder for the recyclerView. I bind the imageButton of the itemView inside the Viewholder. And have set an onClickListener inside the onBindViewHolder. Everything works as expected but the issue is now when i…
2
votes
2 answers

onClick inside ViewHolder doesn't have access to clicked item in adapter

1) Problem I would like to set 2 listeners on 2 buttons inside a CardView. I need to know which item has been selected. I use CardView with RecyclerView and FirebaseRecyclerAdapter (RecyclerView.Adapter) 2) Old Situation I have created the listener…
2
votes
2 answers

Logical pattern for listeners/observers to implement RecyclerView list and details activities

There seems to be various ways to implement RecyclerView lists, some more logical than others. Going beyond a simple list to one where the data changes increases the complexity. Additional complexity comes from implementing the ability to view the…
2
votes
3 answers

Recyclerview ViewHolder : onCreateViewHolder , view binding and onBindViewHolder in the same class

In RecyclerView.ViewHolder , a view is passed to the constructor. This view is an inflated layout. The RecyclerView.ViewHolder only bind the views with findViewById. The RecyclerView.Adapter has the role to : inflate the layout in…
Raymond Chenon
  • 11,482
  • 15
  • 77
  • 110
2
votes
1 answer

Can my RecyclerView.ViewHolder s be a non-static outer class?

I have multiple View types in my RecyclerView. I understand I need to write multiple RecyclerView.ViewHolders. I'm trying to write these in a different package to make the whole project organization cleaner. I know that while using the ViewHolder…
Veneet Reddy
  • 2,707
  • 1
  • 24
  • 40
2
votes
1 answer

How to get view and holder object outside getView method?

I have adapter and fragment. Consider this scenario : Adapter has Edit Text By default edit text is not editable Fragment has one edit icon On click of edit icon adapter's edit text should became editable Here is fragment code:…
2
votes
0 answers

RecyclerView, animate scrolling through list, animate next item, only after the first one has finished

I took my example from here: http://frogermcs.github.io/instamaterial-recyclerview-animations-done-right/ And then my animation looks like this: private void runEnterAnimation(View view, int position) { if (position > lastAnimatedPosition) { …
rosu alin
  • 5,674
  • 11
  • 69
  • 150
2
votes
1 answer

Equivalent of onAttachedToWindow()/onDetachedFromWindow() for a ViewHolder in RecyclerView

I'm converting a bunch of Views to use the ViewHolder pattern in RecyclerView instead. I have code that needs to be run in onAttachedToWindow() and onDetachedFromWindow(), or whatever's closest to it in terms of the View lifecycle. What can I do to…
Mikey Chen
  • 2,370
  • 1
  • 19
  • 31
2
votes
1 answer

Recyclerview with footer not able to delete last item

I am using recyclerview with footer everything is working fine. but i am not able to delete last item. Suppose we have 2 products in list now if user will remove one product then 1 product will remain in recyclerview then i am not able to delete…
2
votes
1 answer

Position on onBindViewHolder() doesn't get updated with item deletion

I have a recyclerview displaying my data. In my adapter class, inside onBindViewHolder(), I have created a listener for a button which deletes a row on click. The first time works just fine, but if I try to delete an item the position value is the…
user3484582
  • 557
  • 1
  • 6
  • 22
2
votes
1 answer

Viewholder of recyclerview getting called for each item

I have Recyclerview in my project which is having one ViewHolder. For this RecyclerView, i have many items to populate, but for the simplicity sake, i have added 100 items. But for these 100 items onCreateViewHolder is being called 100 items i.e.…
Android Killer
  • 18,174
  • 13
  • 67
  • 90
2
votes
1 answer

ViewHolder not setting the string as text of a TextView. Please see details

I am using FastAdapter in my android project. This is how I am using it: public class HRequest extends AbstractItem { public String imageURL; public HRequest() { } public…
2
votes
2 answers

How to show multiple viewholders in recycler view?

I tried to understand how I can easily tell two different views to be inflated depending on some information on the object... My setup is like so but I keep crashing with this error: java.lang.NullPointerException: Attempt to invoke virtual method…
Lion789
  • 4,402
  • 12
  • 58
  • 96
2
votes
2 answers

When not to use ViewHolder pattern?

The purpose of a ViewHolder pattern is to help recycle views. What if in my list I have different layout for each and every row. In my case I have a GridView with 6 elements in two rows. Each element has completely different layout and presents…
Booyaches
  • 1,669
  • 4
  • 27
  • 40
2
votes
2 answers

Checkbox showing multiple time in grid view holder Pattern

i am showing and hiding checkbox on imageview click in gridview but when i click on one imageView checkbox appear on multiple image view android and as i scroll visible checkbox goes missing when i scroll here is my Adapter public class…
bambi
  • 33
  • 8