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

ViewHolder pattern - How to correctly update views

While implementing the viewHolder pattern in an extended ArrayAdapter, and implementing an onClickListener on a Linear Layout, the background color of this LinearLayout gets changed but for other random rows as well! Here is my code (Have stripped…
Saket Jain
  • 1,352
  • 2
  • 12
  • 25
2
votes
1 answer

OnClick event repeats with listview items

I am having a listview in my app. Each listview row expands on tap and a hidden view becomes visible but problem is that hidden view also becomes visible for many others items in the list. I know the reason for this behaviour but I don't know how to…
Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84
2
votes
1 answer

How to change Adapter item resource out of bindViewHolder

I have been stuck in code where I wanted to change the adapter item image source of the active item. I have all set, still getting the active item position and invoking the method from service. I have sendBroadcast method to send the intent with…
2
votes
2 answers

Update ViewHolder values of custom Adapter for Recyclerview

I have a RecyclerView with a custom Adapter to display rectangular elements (about 15, the number can change if the user adds/removes items) in a grid (using Gridlayout Manager). These elements consist of an ImageView and a TextView. I want to…
Eve
  • 1,153
  • 1
  • 15
  • 34
2
votes
1 answer

Accessing the correct height of a object in a recycler view

So, I'm trying to change the height of a ImageView in the onBindViewHolder method of my recycler view depending on the height of another object in the same view holder. When I access the height with getHeight() I get back 0 as a result for the first…
dabo248
  • 3,367
  • 4
  • 27
  • 37
2
votes
0 answers

Strange LinearLayoutManager.scrollToPositionWithOffset(...) behavior

I have a RecyclerView with an Adapter which holds two different kinds of views. The first view has a slightly bigger width and height than the following views. When starting the activity which contains the RecyclerView, I want to scroll to a certain…
2
votes
3 answers

RecyclerView scroll to position and get that view

I want to auto scroll a list item to top (firstVisible item) in my recycler view and get the view at that position, so I can highlight it, from my fragment. So, this is the gist of my fragment code : private void activateNewListItem(int…
2
votes
1 answer

How to check in a listView if spinners are used. Android

I'm working on an android app. I have found how to put dynamically a Spinner in each row. I need that every spinner must be used before the list will be sent to a DB with a click on a button. My problem is with spinners how to check if every spinner…
2
votes
1 answer

Android recyclerView duplicates items on scroll

I'm using ViewHolder pattern and adding custom view to the viewHolder dynamically. the custom view(MetroImageView) duplicates on scroll. My Adapter code is: public class MyAdapter extends RecyclerView.Adapter { private…
user3136364
2
votes
1 answer

How to disable a onLongPressListener in a ViewHolder?

I am trying to temporary disable onLongPressListener that I set in my adapter's ViewHolder. I want to disable it because I want to implement the Drag and Drop functionality (to allow the user to rearrange the items) of the RecyclerView. Currently,…
Georgi Koemdzhiev
  • 11,421
  • 18
  • 62
  • 126
2
votes
1 answer

Get location on screen for view in view holder

I have a Recyclerview that is managed by an adapter. For each item in the recycler I inflate a complex view that contains also a horizontal progressbar which takes the whole width of screen. I have to position a baloon TextView with the percentage…
Stef_ro89
  • 81
  • 1
  • 10
2
votes
1 answer

How to change RecyclerView ViewHolder back to original layout after updating

I have a RecyclerView ViewHolder for a RelativeLayout. In my OnBindViewHolder method, I'm updating the height of the entire layout and a contained ImageView, based on a condition. This works fine, however, this new layout is being recycled for…
Faybian
  • 373
  • 2
  • 7
  • 15
2
votes
3 answers

How to increment a value on view holder variables in android?

I have a viewholder in my Android app and I tried to set an incremented value on a textfield. I tried it like following, Activity @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { …
codebot
  • 2,540
  • 3
  • 38
  • 89
2
votes
1 answer

MoPub Native Ad integration with viewholder pattern in Android

There is a post about this issue. But it is not so detailed. I am using a grid adapter (extends from ArrayAdapter) with viewholder. I wrapped it with MoPubAdAdapter. Ad shows up in gridview but when I click an item, it gives me wrong one (actually,…
sembozdemir
  • 4,137
  • 3
  • 21
  • 30
2
votes
3 answers

How to Increase or decrease value of edittext in listview's each row?

I create one Listview, in my Listview I have two Buttons and one Edittext. In my Edittext I want to increase the value of Edittext as per Button's click. I followed so many tutorials, but still it's not working in my Listview can anyone help me with…
Aditya
  • 1,508
  • 1
  • 19
  • 37