我试过各种代码,但是alert.对话框总是有问题,它没有出现,建议我一个简单的代码
问问题
87 次
1 回答
1
private void alert(context,status,title,message)
{
Builder alertDialog = new AlertDialog.Builder(context);
// Setting Dialog Title
alertDialog.setTitle(title);
// Setting Dialog Message
alertDialog.setMessage(message);
if(status != null)
// Setting alert dialog icon, success and fail is an image
alertDialog.setIcon((status) ? R.drawable.success : R.drawable.fail);
// Setting OK Button
alertDialog.setPositiveButton("OK", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
}
});
// Setting Cancel Button
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int which)
{
}
});
// Showing Alert Message
alertDialog.show();
}
于 2013-07-26T15:57:03.053 回答