• 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:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!