在我们平时见到的应用程序中经常会看到弹出一个对话框用于通知用户下一步的动作,在本实例中实现了一个简单的对话框(在上一实例的基础上),截图如下:
具体的实现代码如下:
AlertDialog.Builder aleBuilder=new AlertDialog.Builder(Notification_Activity.this);
aleBuilder.setIcon(R.drawable.ic_launcher);
aleBuilder.setTitle("Display Dialog");
aleBuilder.setMessage("This is just a display!");
aleBuilder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(Notification_Activity.this, "您点击的是OK按钮!", Toast.LENGTH_LONG).show();
}
});
aleBuilder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
Toast.makeText(Notification_Activity.this, "您点击的是CANCEL按钮!", Toast.LENGTH_LONG).show();
}
});
aleBuilder.show();