一、AlertDialog窗口的新建和显示
new AlertDialog.Builder(EX03_12.this)
.setTitle(R.string.app_about)
.setMessage(R.string.app_about_msg)
.setPositiveButton(R.string.str_ok,
new DialogInterface.OnClickListener() {
public void onClick(
DialogInterface dialoginterface,
int i) {
dialoginterface.cancel();
}
}).show();
二、新建具有菜单功能的AlertDialog窗口
new AlertDialog.Builder(MultiAlertDialog.this)
.setTitle(R.string.app_name)
.setItems(R.array.items,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichcountry) {
String[] aryShop = getResources()
.getStringArray(
R.array.items);
new AlertDialog.Builder(MultiAlertDialog.this)
.setMessage(aryShop[whichcountry])
.setNeutralButton(
"确定",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton) {
/* 在这里处理要作的事 */
}
}).show();
}
})
.setNegativeButton("取消",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface d, int which) {
d.dismiss();
}
}).show();
二、返回键AlertDialog窗口提示退出
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_BACK){
new AlertDialog.Builder(this)
.setIcon(android.R.drawable.ic_menu_help)
.setTitle("提示")
.setMessage("您确定要退出" + getResources().getString(R.string.app_name) + "?")
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
})
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
android.os.Process.killProcess(android.os.Process.myPid()); //获取PID
}
}).show();
return true;
}else{
return super.onKeyDown(keyCode, event);
}
}
- 大小: 18.6 KB
- 大小: 13.4 KB
- 大小: 45.4 KB
分享到:
相关推荐
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 ...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 ...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器——...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器——...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器——...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器——...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互-p60 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器——...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互-p60 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互-p60 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器...
3.12 具有交互功能的对话框——AlertDialog窗口 3.13 置换文字颜色的机关——Button与TextView的交互-p60 3.14 控制不同的文字字体——Typeface对象使用 3.15 如iPhone拖动相片特效——Gallery画廊 3.16 自制计算器...
AlertDialog加载动画弹出框,内置注释,以及AlertDialog属性设置,窗口背景,样式设置,全部设置,下载完了看ChrysanthemumActivity类其他类不用管
layout窗口设计和非layout型窗口设计 alertdialog实现代码
安卓使用弹框做到倒计时的用法,分别使用MaterialDialog、AlertDialog来做了一个小demo
alertdialog自定义,大家可以看看哟,挺不错的
当我点击确定按钮,也就是 AlertDialog 里的 PositiveButton 的时候,我们需要判断用户是输入是否符合我们的预期,如果不符合通常提示用户重写输入,且不关闭当前的对话框,但上图中点击按钮后会自动的关闭窗口。...
1. 在Android SDK中,虽然有许多的窗口,有些类似Modeless的窗口、有些类似于前端Force Focus的窗口,但真正具有交互功能的则为AlertDialog对话窗口。 new AlertDialog.Builder(EX03_12.this) .setTitle(R.string....