-5

here is the code:

public void onClick(DialogInterface dialog, int whichButton)
    {
        Toast.makeText(getBaseContext(), "Cancel clicked", Toast.LENGTH_SHORT);

    }
}
builder.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();

    }
});  

i am getting a number of curly braces related errors though code seems correct to me.. please help!!

4

4 回答 4

0
public void onClick(DialogInterface dialog, int whichButton)
    {
        Toast.makeText(getBaseContext(), "Cancel clicked", Toast.LENGTH_SHORT).show();<//here you missed to call show method

    }
}

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

    }
});//here to add ')' before semicolon
于 2013-06-03T10:14:41.080 回答
0
public void onClick(DialogInterface dialog, int whichButton)
    {
        Toast.makeText(getBaseContext(), "Cancel clicked", Toast.LENGTH_SHORT);



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

    }
});
}
于 2013-06-03T10:06:36.250 回答
0

您只需要在最后一行添加一个简单的括号')'。

});

见下文

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

    }
});
于 2013-06-03T10:10:25.350 回答
0

用这个替换你的代码......

builder.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();
}
});
于 2013-06-03T10:07:46.897 回答