• 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
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

Set Switch State Based on Comparison of Values in an ArrayList and a TextView

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a RecyclerView that displays a list of applications currently installed on the device. Each row includes the name of the application, its package name, and a switch. When the Switch isChecked, the package name is added to an ArrayList. If the user clicks back into that Activity, I need to repopulate the list and set the state of Switches based on what was previously added to the ArrayList.

The overall idea I have is to do a comparison of the package names in the RecyclerView to those stored in the ArrayList, and when there is a match the Switch for that row needs to be set to checked.

The problem is that I am not sure how to best accomplish this. I think it needs to be done in the Activity and not the Adapter, since there is on onCreate() in the Adapter. I know it is also going to involve a loop.

Anyone have any idea how to do this?
 
Get out of my mind! Look! A tiny ad!
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic