Android multiple choice list dialog tutorial



16
109692

In this tutorial you will learn how to use Android multiple choice list dialog, this will allow you to select multiple items from the list in android alertdialog. Here is how to do it: - Add an Android button to xml layout - Initialize the button and then make it clickable by calling setOnClickListener - Inside the setOnClickListener is where we are going to define alertdialog.builder - We give a title for the dialog and make sure to add dialog.setCancelable(false) to prevent user from closing the dialog when clicking in any area outside the dialog - Call dialog.setMultiChoiceItems and then pass items array, boolean array and set OnMultiChoiceClickListener - Call dialog.setPositiveButton and give it a label, inside this button is where we are going to add the checked items to the list and make sure that those are item not duplicated - Call dialog.setNegativeButton and give it a label, inside this button we are going to dismiss the dialog by calling dialog.dismiss() - Call dialog.setNeutralButton and give it a label, inside this button we are going to reset/uncheck items in android alertdialog - Call the dialog.show() to show the dialog That's it!! - Github project source code: https://github.com/codingdemos/MultichoiceTutorial Social media: ▶Twitter: https://twitter.com/codingdemos

Published by: Coding Demos Published at: 7 years ago Category: آموزشی