您的位置:首页 > 移动开发 > Android开发

android AlertDialog 对话框的基本使用

2017-11-25 13:25 495 查看
/**
* @setIcon 设置对话框图标
* @setTitle 设置对话框标题
* @setMessage 设置对话框消息提示
* setXXX方法返回Dialog对象,因此可以链式设置属性
*/
private void showNormalDialog() {
final AlertDialog.Builder normalDialog =
new AlertDialog.Builder(ModifyActivity.this);
normalDialog.setIcon(R.drawable.h100);
normalDialog.setTitle("标题内容");
normalDialog.setMessage(tv.getText());
normalDialog.setPositiveButton("确定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//...To-do
hcontent = h_content.getText().toString();
hoperate = tv.getText().toString();

}
});
normalDialog.setNegativeButton("关闭",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//...To-do
}
});
// 显示
normalDialog.show();
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: