alertdialog显示checkboxes的有关问题

alertdialog显示checkboxes的问题

想在alertdialog上显示一个多个选项的对话框如下

public void showSettingsBox(){ 
 
final CharSequence[] items = {"Item1", "Item2", "Item3"}; 
 
final boolean checked[] = new boolean[]{false,false,false}; 
 
 
AlertDialog.Builder builder = new AlertDialog.Builder(fLabyrinthGame);  
  builder
.setMessage(fMessage) 
   
.setCancelable(false) 
   
.setMultiChoiceItems(items, checked, new OnMultiChoiceClickListener() { 
 
   
@Override 
   
public void onClick(DialogInterface dialog, int which, boolean isChecked) { 
     
CharSequence text = "Item number " + which; 
     
int duration = Toast.LENGTH_SHORT; 
 
     
Toast toast = Toast.makeText(fLabyrinthGame, text, duration); 
     toast
.show(); 
 
   
} 
   
}) 
   
.setPositiveButton("Apply", new DialogInterface.OnClickListener() { 
   
public void onClick(DialogInterface dialog, int id) { 
     dialog
.cancel(); 
   
} 
   
}); 
  builder
.setTitle(fTitle);  
  builder
.setIcon(R.drawable.icon_exclamation);  
 
 
AlertDialog alert = builder.create();  
 
  alert
.show();    
 
} 
结果出现一个空白除了最后一个按钮

 

要想实现功能需要去掉setMessage(fMessage),这是因为setMultiChoiceItems or setItems 是互相冲突的貌似

1 楼 njlz8888 2011-08-02  
我也遇到这个问题了,请问您是怎么解决的??