0

I have a requirement like the student names will be taking from the db and showing it in an alert box. a checkbox should be displayed for each student name in that alert so that the user can select the student names from alert box.I have done with the student names.Can any one give an idea to display the checkbox for each student

public void Show_friends()
{
         AlertDialog.Builder builder1 = new AlertDialog.Builder(this);
     try
     {
        builder1.setItems(paymentby,new DialogInterface.OnClickListener() 
        {
         public void onClick(DialogInterface dialog, int item) 
         {

         }
         }
        );
        AlertDialog alert = builder1.create();
        alert.show();


     }
     catch (Exception e) {
        System.out.println("Gesture exception caught");
    }
     System.out.println("================vij=========================inside if");

}
}

This is my code

V I J E S H
  • 7,464
  • 10
  • 29
  • 37
  • see this link it may help you.. http://stackoverflow.com/a/10933605/1168654 http://stackoverflow.com/a/10652886/1168654 – Dhaval Parmar Jul 03 '12 at 12:37

2 Answers2

0

You will be needing custom dialog to perform this task. see this to know how you can do it.

Waqas
  • 4,411
  • 6
  • 27
  • 31
0
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Select the Friends");

    builder.setMultiChoiceItems( paymentby,null, new OnMultiChoiceClickListener()
    {
        public void onClick (DialogInterface dialog, int which, boolean isChecked)
        {


        }
        } 
    ) ;

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener()
    {   
        public void onClick(DialogInterface dialog, int id)
        {         


            }
        }
    );


    AlertDialog alert = builder.create();
    alert.show();

Thanks...

V I J E S H
  • 7,464
  • 10
  • 29
  • 37