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

Call notifyItemChanged(int position) or equivalent from RecyclerView.ViewHolder

My RecyclerView items contains views that have 4 TextViews. I "collapse" and "expand" each view item by setting 2 TextViews' View.visibility to View.GONE and View.VISIBILITY respectively by implementing onClick(View view). I know I must call…
sziraqui
  • 5,763
  • 3
  • 28
  • 37
2
votes
2 answers

Imageview not on correct row after scrolling in Recyclerview

I have an app that displays my e-mail via microsoft graph api. Everything but 1 things i working fine so far. When the list first loads in, all info is correctly displayed, but when i scroll down, then back up. The imageview of the attachement sits…
2
votes
2 answers

RecyclerView not calling getItemCount

I've investigated several SO answers on this question (here, here, and here) and none of the proposed solutions have worked. My problem is that my RecyclerView list items aren't being displayed. I've set breakpoints in MessengerRecyclerAdapter,…
2
votes
2 answers

Handle click events in Adapter/ViewHolder

Currently: I'm implementing click events in my Adapter inside of onBindViewHolder, but I have noticed that the adapter positions get messed up when doing this. I done some research and found this, where he state: As for why it is better in the…
ClassA
  • 2,480
  • 1
  • 26
  • 57
2
votes
1 answer

Is it a bad practice to hold a reference for the list item inside the ViewHolder

I usually use an interface to handle clicks on the list item, either to show a message, or take an action public interface ItemClickListener { void onItemClicked(int adapterPosition); } @OnClick(R.id.seat_btn) protected void click() { if…
atabouraya
  • 3,233
  • 1
  • 26
  • 31
2
votes
2 answers

Images in RecyclerView do not appear on start up

I have a RecyclerView with a list of cards in it, and each has a spot for a picture. When I scroll down initially, the cards that began off-screen have their images loaded once they appear on-screen, but the cards that began on-screen only have…
2
votes
1 answer

How to populate RecyclerView with AppWidgetHostViews?

I am trying to populate RecyclerView with AppWidgetHostViews but I'm not really sure how to do that. I found a way in which they create a LinearLayout, cast it to ViewGroup and call viewList.add(hostView). I would like to create RecyclerView instead…
joe
  • 1,341
  • 4
  • 21
  • 32
2
votes
1 answer

Setting hover for items in recyclerview

I have a listview in that I have recylerview of cardviews...when i select any of them then a floating layout should be there which has 3 buttons. I am using this library enter link description here. I am using this library in a adapter and have set…
hiashutoshsingh
  • 980
  • 2
  • 14
  • 41
2
votes
2 answers

How to sort items in RecyclerView depending on a Date

This is what my screen should look like. I added this library https://github.com/ShamylZakariya/StickyHeaders and tried to do it in similar way. My model looks like this: public class Transaction { private int id; private Date createdDate; private…
joe
  • 1,341
  • 4
  • 21
  • 32
2
votes
2 answers

Android - Programming Style - RecyclerView - Use SetText in ViewHolder or in onBindViewHolder?

When setting OnClickListeners to items in the RecyclerView it's recommended to do that in the inner class like this: public ViewHolder(View itemView) { super(itemVIew); nameTextView = (TextView) itemView.findViewById(R.id.item_name); …
2
votes
1 answer

How to call ViewHolder method from Activity/Fragment

I have three classes viz. an Fragment, a RecyclerViewAdapter and a RecyclerViewHolder. They work in the usual way. But now I got a problem, I need to call a method in the ViewHolder from the said Activity. I was thinking of using callbacks but I…
X09
  • 3,827
  • 10
  • 47
  • 92
2
votes
0 answers

How Recycler View Holder.ItemView recycle

In my case , I got Exception if (holder.isScrap() || holder.itemView.getParent() != null) { throw new IllegalArgumentException( "Scrapped or attached views may not be recycled. isScrap:" +…
Lonie
  • 275
  • 2
  • 12
2
votes
1 answer

Error with many CountDownTimers in RecyclerView ViewHolders

I'm displaying a variable number of ViewHolders in a RecyclerView, each with a unique CountDownTimer in it, displayed in a TextView. If I don't have a large number of ViewHolders in the RecyclerView then the CountDownTimers tick down as expected,…
2
votes
1 answer

Android - "No enclosing instance of type 'some.abstract.class.name' class is in scope" error when extended

I have an abstract adapter class from an external library: public abstract class DragItemAdapter extends RecyclerView.Adapter { //Their other codes public class ViewHolder extends…
Tran Hoai Nam
  • 1,273
  • 2
  • 18
  • 35
2
votes
2 answers

access menu items from ViewHolder - android

i am working on recycler. this is my adapter class: public class NotesAdapter extends RecyclerView.Adapter { private static List mNotes; private Context mContext; public NotesAdapter(Context context, List
varsha valanju
  • 801
  • 1
  • 9
  • 27