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
3
votes
0 answers

Can I update ViewHolder variable from an Activity?

I down know if made it right. I have a RecyclerView with 2 ViewHolders. ProgramHolder and CountDownTimerHolder. In the CountDownTimerHolder is the time where the countdown starts predifined. If you click on the Settings Button, I start a new…
3
votes
3 answers

Setting onClickListener to the whole item in onBindViewHolder

I have an RecyclerView Adapter and I want to set the onClick to the whole item but this code and when I also tried it with myViewHolder.view.setOnClickListener(..) both still only listened to the click of the checkbox. How can I set the…
3
votes
0 answers

Problem with nested RecyclerView + ItemDecorator + DiffUtil

I have a problem with refreshing nested recyclerview with DiffResult. I have a parents list and each parent has children list. When I want to refresh whole list then I calculate DiffResult of parents list and DiffResult of children for each parent.…
3
votes
0 answers

RecyclerView.Adapter getItemViewType returning wrong value

Following is my adapter code public class FoodMenuRecyclerAdapter extends RecyclerView.Adapter { List objects; FoodMenuParentListener foodMenuParentListener; boolean isAddAllowed; boolean isVegOnly; static final…
amodkanthe
  • 4,345
  • 6
  • 36
  • 77
3
votes
4 answers

OnClickListener in ViewHolder not being entered

I have a recycler view displaying all posts made by a user in my app. I want the users to be able to click on one of the posts and be brought to a new fragment where they can only see the post they have chosen. When I run my code, and click on one…
3
votes
1 answer

Gone elements in ConstraintLayout leaves ghost space

So I have a layout file for a RecycleView which has expandable/collapsible viewholders. Clicking on the header would expand/collapse the extra data. Everything looks fine in the editor. However, it would have a ghost space similar to…
3
votes
1 answer

RecyclerView.clear()? Is there a method to clear() or invalidate a viewholder data individually?

I came across the documentation for AsyncPagedListDiffer. I'm wondering how we can call holder.clear() when holder is a RecyclerView.ViewHolder instance. Maybe they have an in-house method which accommodates this clearance functionality?
3
votes
0 answers

Android: TextView setText in custom adapter not changing the UI

I'm trying to make a dictionary with two TextViews - 1 for the word, 1 for the translation. On long press, an edit button will popup that will show an alert dialog on click. The alert dialog takes two inputs, new word and new translation, edits the…
Tom
  • 31
  • 1
3
votes
3 answers

Using different views in onCreateViewHolder

I followed this tutorial by Google Developer's YouTube channel to implement AdMob native express ads. I got the following error: required: packagename.adapter.viewHolder found : packagename.adapter.NativeExpressAdViewHolder Here is how my…
ClassA
  • 2,480
  • 1
  • 26
  • 57
3
votes
1 answer

Dynamic items in viewholder on RecyclerView

If we have N categories (between 1 and 100 according to a REST API) and each with X items (between 1 and 50, depending on the category), what is the best way to do a category RecyclerView? To add do this I am adding card views for each item item of…
3
votes
2 answers

Android - Get row from RecyclerView.findViewHolderForAdapterPosition()

I need to get a reference to a specific row within my recyclerView. I used to do it like this View row = recyclerView.childAt(position); since the childAt() method is based on the ViewGroup, once the list is scrolled, the positions are messed up. I…
Daniele
  • 4,163
  • 7
  • 44
  • 95
3
votes
2 answers

How to open camera , or call startActivityForResult from a button in recycleriew item

I am trying to open the camera while clicking on the button Photo , but this button is in an adapter of a recyclerview , and I couldn't call startActivityForResult , is there any way to do it ? or something else to start the camera and take pictures…
user8392611
3
votes
1 answer

java.lang.InstantiationException, instantiating RecyclerView.ViewHolder

I am inflating two types of views for a chat in, in My other activity called ActivityA works great but, in my activity B I use the same process but it does not work Problem occurs in OnCreateView holder In the part of 'return…
3
votes
2 answers
3
votes
1 answer

Item in RecyclerView not aligning as expected

My app has a chat activity which contains a recyclerview. This recyclerview contains two items that display the messages received by the user and the messages sent by the user. The messages received by the user is aligning from the left of the…