• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Recall selections when using .setMultiChoiceItems with AlertDialog  RSS feed

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have implemented multiple checkboxes in an AlertDialog. However, I am now looking for a simple way to recall the selected checkboxes if the AlertDialog is reopened.

The issue arises here...



A new instance of the AlertDialog is called every time. So, I was supposing that if there was a way to preserve the previous state, that should do the trick. Does anyone have experience doing this? Or suggestions?

Thanks y'all!
 
Adam Wentz
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, after doing extensive digging, I came across this tutorial:

Show/Create AlertDialog with multiple choices in android

It resolves the issue of recalling previous selections in the checkbox AlertDialog by utilizing a boolean array. It needed only minor tweaking to make it work perfectly for my purpose.

In the event that the aforementioned page should become unavailable in the future, here is the code from the referenced tutorial:

MainActivity.java



activity_main.xml
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!