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
9
votes
4 answers

RecyclerView's row is shuffling and change Images : android

Changes in Question as other issue is fixed. My issue is when Recycler View is scrolling Up and Down Row item changes it's position when scrolling fast and get back to it's original position. Row item makes it's some portion fix as…
Abhishek
  • 2,350
  • 2
  • 21
  • 35
8
votes
6 answers

getActivity() inside viewholder

I have created a Recyclerview, with itemobjects, Adapter, viewholder and activity. The Recyclerview works fine. My problem is when an item is clicked from Recyclerview, I want to direct the user to TicketDetails activity. I have the code to get the…
Sathya Baman
  • 3,424
  • 7
  • 44
  • 77
8
votes
5 answers

Android: Changing visibility of a view in recyclerView

I have implemented a recyclerView in my project. I have a Button in my recyclerView row. The code for my each row of recyclerView is like this: savedmessage_custom_row.xml
8
votes
1 answer

What causing this exception java.lang.RuntimeException: java.lang.NoSuchMethodException: [class android.view.View]

I'm having a problem with my firebase project. I followed the steps on firebase GitHub documentation, but I got this exception java.lang.RuntimeException: java.lang.NoSuchMethodException: [class android.view.View] this is a ViewHolder class…
8
votes
2 answers

Recyclerview viewholder possible to change views at other adapter positions (not current position)?

I have a recyclerview with mediaplayer to play a song on each row. I only have one button for play/stop which changes symbol. Here is my problem: Example 1 (This works fine): (For adapter position 1) the user hits the play symbol and music plays…
8
votes
1 answer

should viewholder hold reference to the adapter?

I am reading the sample code from Google, the code is like this: public class AttractionListFragment extends Fragment { ... private class AttractionAdapter extends RecyclerView.Adapter implements ItemClickListener { public…
Yong Liu
  • 111
  • 3
8
votes
3 answers

About RecyclerView.ViewHolder and RecyclerView.Adapter

The RecyclerView.ViewHolder class has a field that is public final View itemView. It says that the onBindViewHolder method should update the contents of the itemView to reflect the item at the given position . Doesn’t the final modifier indicate…
8
votes
5 answers

OnMapLoadedCallback and OnMapReadyCallback, when to use which?

While working a ViewHolder of GoogleMap Lite, as part of the row in RecyclerView, I'm looking for callback to set the pins location when the Map is ready. I found both function below. OnMapLoadedCallback :…
Elye
  • 53,639
  • 54
  • 212
  • 474
8
votes
2 answers

Android: How to access viewholder at position (from outside the adapter)

I have a recycler view adapter. So it hosts 3 views. Simply each view has ImageView. When a user clicks on image (1 out of 3) It creates new intent to use a photo app and returns it to caller when done. The caller (the activity, which created…
vankiz
  • 106
  • 1
  • 6
7
votes
3 answers

How to make RecyclerView with Composable ViewHolder render faster?

As per https://developer.android.com/jetpack/compose/interop/compose-in-existing-ui#compose-recyclerview, the composable ViewHolder that can be used in RecyclerView is as below import androidx.compose.ui.platform.ViewCompositionStrategy class…
Elye
  • 53,639
  • 54
  • 212
  • 474
7
votes
2 answers

View margin not working after using databinding

Below is the code of the item layout of gridview. In this, the layout_margin is there in the design panel but when I run the there is no margin. I tried to check other tags like the background and found that it was working. A similar problem is…
7
votes
1 answer

Manually created view in ViewHolder created in onCreateViewHolder

I would like to make generic adapter which let me reuse it. That's why I decided to not to create view by inflating, but pass custom, previously created view to ViewHolder in ListAdapter (RecyclerView) in onCreateViewHolder. According to its…
user3448282
  • 2,629
  • 3
  • 25
  • 47
7
votes
3 answers

Getting two different views in single RecyclerView using Firebase in Android

I have developed an application in which there are two posts The image post using picasso the Video post using Youtube Api. I have implemented both by using RecyclerView and Firebase recyclerAdapter but the problem is that I dont know that how to…
7
votes
1 answer

Best way to notify RecyclerView Adapter from Viewholder?

I have a RecyclerView with multiple item view types so they are broken into separate ViewHolder classes. Before, when all the ViewHolders were in the same class as the RecyclerView Adapter, I could update the adapter directly when an item was…
7
votes
1 answer

RecyclerView is creating ViewHolders for all items at once

I have main RecyclerView which contains other RecyclerViews (let's call them subRecyclerViews). The number of subRecyclerViews is based on the data received from server. The problem is, that whenever a subRecyclerView is about to become visible, it…
Mischmo
  • 75
  • 2
  • 7