Win a copy of Hands On Software Engineering with Python this week in the Jython/Python forum!
  • 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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
 
This is my favorite tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!