Guest User

Untitled

a guest
Aug 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. Save Selections DialogInterface.OnMultiChoiceClickListener
  2. new AlertDialog.Builder(this)
  3. .setTitle("Weekdays")
  4. .setMultiChoiceItems(weekdayOptions, selections, new DialogInterface.OnMultiChoiceClickListener()
  5. {
  6. public void onClick(DialogInterface dialog, int whichButton, boolean isChecked)
  7. {
  8.  
  9. if( selections[whichButton] == true)
  10. {
  11. //Only need the selected(True) values
  12. Log.d(TAG, "Choice: " + whichButton);
  13. }
  14.  
  15. Log.d(TAG, "Weekdays Selected: " + whichButton + selections[whichButton]);
  16. selections[whichButton] = isChecked;
  17. }
  18. })
  19. .setPositiveButton("OK", new DialogButtonClickHandler())
  20. .create()
  21. .show();
  22. }
  23.  
  24.  
  25. public class DialogButtonClickHandler implements DialogInterface.OnClickListener
  26. {
  27. public void onClick( DialogInterface dialog, int clicked )
  28. {
  29. switch(clicked)
  30. {
  31. case DialogInterface.BUTTON_POSITIVE:
  32. //I want to check here what the user selected
  33. break;
  34. }
  35. }
  36. }
Add Comment
Please, Sign In to add comment