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

How to get respective text and image from the respective recyclerview item in floaty upon clicking a button?

I'm retrieving some data from Firebase and showing it using RecyclerView. My RecyclerView has cards in it in which the text and images are getting retrieved. The card has a button on it which starts a floaty. The floaty has a ImageView and a…
3
votes
1 answer

How does RecyclerView gets 1 extra View from Adapter when we scroll

Snap 1:13 Views when Activity Starts. https://i.stack.imgur.com/EoDY2.jpg Snap 2:14 Views 1 at top + 1 at bottom. https://i.stack.imgur.com/barIm.jpg i am kinda new to android and trying to understand the RecyclerView. What a Recycler does is when a…
3
votes
2 answers

RecyclerView adapter taking wrong values during scrolling

I have read several questions on stackoverflow addressing this problem but I could not solve my problem. The recyclerview shows webviews. My issue is that the adapter, initially, load the right values (below image): but when I scroll down, and…
3
votes
0 answers

Dynamic RecyclerView displays available contacts and search for contacts

Below is the code for onCreateViewHolder() Method. Here i'm checking if list is empty or not. I've a searchView to search contacts. When there is no contacts with search name then the layout "no_contacts" will be displayed. But when i press…
Mohd Asif Ahmed
  • 1,880
  • 2
  • 15
  • 29
3
votes
1 answer

Encapsulate ViewHolder Functionality for reuse

I have an application with a news feed. I am using a recycler view to populate my news feed. I have 10 variations of viewholders for the recycler view depending on what type of content received from the server. That all works fine. My problem is…
DJ-DOO
  • 4,545
  • 15
  • 58
  • 98
3
votes
2 answers

How to connect RecyclerView's ViewHolder and the container activity/fragment?

I made the ViewHolder itself as its OnClickListener: public class ListItemViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { ... @Override public void onClick(View view) { ... } } Now I can handle…
7bitex
  • 113
  • 1
  • 5
3
votes
2 answers

Changing drawable in RecyclerView updates all rows

I am trying to get the 'like' button functionality in my application just like to Facebook. What i want is that whenever the user clicks on the like button, the color of the drawable on the button should change from grey to blue. I am using…
tintin21
  • 255
  • 3
  • 14
3
votes
3 answers

View Holder Stability Issue

I am uploading data to server, and if data successfully uploaded to server then i am showing "Saved", like you can see "Uploaded" for image. But the issue is, i have stored data for the first item row, whereas getting "Saved" text in different row…
Sun
  • 6,768
  • 25
  • 76
  • 131
3
votes
2 answers

RecyclerView.Adapter notifyItemChanged() with async network update?

I have a RecyclerView using a LinearLayoutManager, and a custom RecyclerView.Adapter. When a user long-clicks an item, it triggers an asynchronous network refresh of only that item. I know the item's position at the time of the long-click, and I can…
ExactaBox
  • 3,235
  • 16
  • 27
3
votes
2 answers

ViewHolder ImageView setVisibility is repeated

I have an adapter with the ViewHolder pattern. It has a TextView and an ImageView. I have to do some check with database in the adapter to show the ImageView or not. The problem is that is set the visibility to View.VISIBLE also to other ImageView…
Giorgio Antonioli
  • 15,771
  • 10
  • 45
  • 70
3
votes
1 answer

ViewHolder messing Views

I have implemented both a ViewHolder and a convertView in my listView. My listView is populated by a custom adapter, with a list of bookings. When I click on an item, an invisible layout slides in from right to left, to display buttons. I can…
3
votes
2 answers

ViewHolder in RecyclerView.Adapter not specific to position

The following is part of my code for onBindViewHolder (inside MyAdapter extends RecyclerView.Adapter) @Override public void onBindViewHolder(ViewHolder holder, int position) { // - get element from your dataset at this…
3
votes
1 answer

Referencing the Activity in a ViewHolder

Is it safe to keep a handle to the Activity in a ViewHolder that is stored with the setTag method? I found this issue that claims that storing a reference to the Activity could result in memory leaks, but it has been fixed in Android 4.0:…
2
votes
1 answer

How to prevent admob native ads in recyclerview from recycling or reloading when scrolling down/up

I successfully added the AdMob native ads in my app, every 10 items it loads and show one ad, the problem is when I scroll out from it it's destroyed and the second list (10 items) load the second ad, and so on..., to understand issue see this…
Dr Mido
  • 2,414
  • 4
  • 32
  • 72
2
votes
2 answers

Strange behaviour happen in onBindViewHolder android kotlin

Hey I am working in android kotlin. I am working in reyclerview. I want to do single selection in my items. I tried some code which is working fine. OptionsViewAdapter.kt class OptionsViewAdapter : ListAdapter