我对这个我试图实现的android代码感到非常困惑。我在返回新的AlertDialog.Builder(这个)时遇到语法错误,它告诉我.setMultiChoiceItems无法识别。
任何人都可以帮我解决这个问题吗?
@Override
protected Dialog onCreateDialog(int id){
switch(id){
case 0:
return new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("This is a dialog with some simple text...")
.setPositiveButton("OK", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton)
{
Toast.makeText(getBaseContext(),"OK clicked!", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int WhichButton){
Toast.makeText(getBaseContext(),"Ok clicked!", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton){
Toast.makeText(getBaseContext(),"Cancel clicked!", Toast.LENGTH_SHORT).show();
}
}).setMultiChoiceItems(items, itemsChecked, new DialogInterface.OnMultiChoiceClickListener() {
public void onClick(DialogInterface dialog, int which, boolean isChecked){
Toast.makeText(getBaseContext(), items[which] + (isChecked ? " checked!": " unchecked!"), Toast.LENGTH_SHORT).show();
}
}
)
.create();
}
return null;
}