Click here to Skip to main content
11,636,260 members (82,129 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: Java Android
Hello friends, I am a new to Android development. I want to show a Listbutton dialog box with multichoiceitems options in android. for that I have used the below code.

I am calling this dialog box on button click event.
I am able to see the title and message I set for that dialog box, and button also is visible but I am unable to get the list of colors that I am setting to the dialog.

here is my code

btn=(Button) findViewById(;
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v)
final ArrayList<String> selColors=new ArrayList<String>();	
		AlertDialog.Builder dialog1=new AlertDialog.Builder(getApplicationContext());
		final String[] Colors={"Red",”Green”,”Blue”,”Orange”,”Pink”};
		final boolean[] _selections = {true,true,true,true,true,true,true};
		dialog1.setTitle("Colors List");
		dialog1.setMessage("Select Your Favoriate Color");
		dialog1.setMultiChoiceItems(Colors, _selections, new DialogInterface.OnMultiChoiceClickListener()
	public void onClick(DialogInterface dialog, int which, boolean isChecked)
	selColors.add(Colors [which]);
	Toast.makeText(getApplicationContext(),"You have selected " + Colors [which],Toast.LENGTH_SHORT).show();
	dialog1.setPositiveButton("OKAY", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog1.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
catch(Exception ex)
TextView tv=(TextView) findViewById(;

Please provide me what may be the wrong. Why I am unable to call the event I mean nothing is happening when I click the button.

Posted 12-Jan-13 0:07am
Edited 12-Jan-13 2:21am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 333
1 OriginalGriff 283
2 Sergey Alexandrovich Kryukov 255
3 Suvendu Shekhar Giri 225
4 Mika Wendelius 204
0 OriginalGriff 8,941
1 Sergey Alexandrovich Kryukov 8,459
2 Mika Wendelius 6,849
3 F-ES Sitecore 2,364
4 Suvendu Shekhar Giri 2,320

Advertise | Privacy | Mobile
Web02 | 2.8.150728.1 | Last Updated 12 Jan 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100