• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Changing View Visibility in RecyclerView

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Rv with imageViews and checkboxes, i'm trying to hide the imageviews and unhide the checkboxes on long click for all the list item and,only the visible item's view only changes but not the other item's views and also the view changes back to original when scrolling.so far i can do this with the following code.



Is there any good way to do what i want..
 
Saloon Keeper
Posts: 7597
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused. You said both "i can do this" and "Is there any good way to do what i want." - those two statements would seem to contradict each other. If the code you posted does not do what you intend, what does it do instead? And where, specifically, are you stuck making the require changes?
 
dev goku
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok,i have text,imageview and chechboxes on the RV, I want to change the images to ckeckbox for every item on Long click ,I use HashMaps here,but  on long Click the visible items in the viewholder changes and while scrolling i can see few items has also changed but not all the items after that and the changed items also seems to change its visbility back to original.
 
Tim Moores
Saloon Keeper
Posts: 7597
177
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that the MyViewHolder constructor sets the state for all items (in lines 33 and 34), when it should set those values only for the newly constructed item. You would call getAdapterPosition()  to find out which one that is.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic