在android中识别模块的问题

时间:2011-09-06 19:35:22

标签: java android overloading

我对这个我试图实现的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;
}

0 个答案:

没有答案