2012-07-03 48 views
0

我有一個要求,例如學生姓名將從數據庫中取出並顯示在警告框中。一個複選框,應在警報顯示每個學生的名字,以便用戶可以選擇從警報box.I學生的名字都與學生做names.Can任何人給一個想法,以顯示覆選框每個學生在警報中添加動態數量的複選框

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"); 

} 
} 

這是我的代碼

+0

看到這個鏈接,它可以幫助你.. http://stackoverflow.com/a/10933605/1168654 http://stackoverflow.com/a/10652886/1168654 –

回答

0

您將需要自定義對話框來執行此任務。請參閱this瞭解如何做到這一點。

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(); 

謝謝...