1.
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("确认" ) ;
builder.setMessage("这是一个简单消息框" ) ;
builder.setPositiveButton("是" , null );
builder.show();
2.
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("请输入");
builder.setIcon(R.drawable.ic_launcher);
builder.setView(new EditText(MainActivity.this));
builder.setPositiveButton("是" , null );
builder.setNegativeButton("否", null);
builder.show();
3.
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("确认" ) ;
builder.setMessage("是否确认?" ) ;
builder.setPositiveButton("是",null );
builder.setNegativeButton("否", null);
builder.show();
4.
AlertDialog.Builder builder = new Builder(MainActivity.this);
builder.setTitle("请选择");
builder.setIcon(R.drawable.ic_launcher);
builder.setSingleChoiceItems(new String[]{"选项1","选项2","选项3","选项4"}, 0, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
dialog.dismiss();
}
});
builder.setNegativeButton("Cancel",null);
builder.show();
5.
builder.setTitle("这是多选框");
builder.setIcon(R.drawable.ic_launcher);
builder.setMultiChoiceItems(new String[]{"选项1", "选项2", "选项3", "选项4"}, null, null);
builder.setPositiveButton("sure",null);
builder.setNegativeButton("cancel",null);
builder.show();