重写:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0: {
Dialog dialog = new AlertDialog.Builder(Test.this).setTitle("Question")
.setMessage("Are you sure that you want to quit?") // 设置内容
// .setView(input)//这个view显示在message下面
.setPositiveButton("Yes", // 设置确定按钮
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
setResult(RESULT_OK);
finish();
}
}).setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).create();// 创建
return dialog;
}
default: {
return null;
}
}
}
在oncreat
showDialog(0);
第二种:
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case 0: {
return new AlertDialog.Builder(mima.this)
.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (event.getKeyCode() == KeyEvent.KEYCODE_SEARCH) {
return true;
}
return false;
}
})
.setTitle("实验:")
.setMessage("这是一个测试")
.setPositiveButton("确定",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
removeDialog(0);
}
})
.setNegativeButton("不再显示",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
removeDialog(0);
closeShowPwdTip();
}
})
.setNeutralButton("设置", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
removeDialog(0);
// startSettingActivity();
}
}).create();
}
default: {
return null;
}
}
}
分享到:
相关推荐
alertDialog,android alertDialog大全
2、将AlertDialog的EditText中的值设置到Activity的TextView中 新手在自定义AlertDialog上的疑问笔者猜测主要有两个: 1、自定义的layout如何放到AlertDialog中? 解答: 获取到layout的view之后,直接调用...
Android之AlertDialog源码
AlertDialog 各种各样的对话框和结合popupwindow使用
Android AlertDialog对话框 自定义实现遮罩层
* 各种功能实现弹窗(自定义弹窗位置,添加动画效果) * 1.设置AlertDialog弹窗并且2秒后自动关闭(自定义关闭AlertDialog) * 2.设置popuwindow弹窗并且2秒后自动关闭 * 3.弹出后自带震动提示
Android之修改AlertDialog对话框及使用系统Holo风格
Android入门第九篇之AlertDialog.docx
android自定义AlertDialog,例如支付页面,先弹出自定义AlertDialog询问是否愿意支付,确定则弹出另外一个自定义AlertDialog,选择支付方式,android自定义AlertDialog,android自定义AlertDialog,android自定义...
android AlertDialog使用例程 一个在安卓平台上开发使用AlertDialog的例子 很实用很全哦
AlertDialog的各种用法,包含简单、复杂、列表、自定义、日期时间、进度条等的对话框
025_android UI组件之 AlertDialog 的各种实现,很细致的视频教程,这个可以学哦。。
警告框AlertDialog,实现点击弹出警告框,适合初学者下载学习
android 使用alertdialog创建自定义对话框
android AlertDialog对话框的类型集合 ,比较全面的讲述了 AlertDialog 的 种类 , Demo 的综合性比较强 , Demo 可直接运行
自定义AlertDialog(仿微信)