Android(安卓)Dialog 对话框例子
16lz
2022-01-16
阅读更多
*
*
*
*/
public class DialogDemo extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
this.setContentView(R.layout.main);
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("对话框")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).show();
// AlertDialog.show(this, "This Dialog Demo",
// R.drawable.icon, "That's a file, not a directory", "Cancel", false);
}
}
上面就是一个简单的Dialog的例子,
如果想知道高级的一些用法,可以查看AlertDialog的API相关文档
http://www.3geye.net/bbs/thread-614-1-1.html
这回我们来研究下Android的Dialog的用法。看看难不难用。
跟J2ME 的Alert比起来谁的更容易上手。Let‘s Go。
package com.gggeye.android;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
/**
* 对话框的例子
*
*
*
* 创建日期 2007-11-15
* @author wuhua
*
MSN gggeye@hotmail.com
*
EMAIL gooogledev@gmail.com
*
网站支持 http://www.3geye.net
*
网站论坛 http://www.3geye.net/bbs
*
wuhua的博客 http://wuhua.3geye.net
*/
public class DialogDemo extends Activity {
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
this.setContentView(R.layout.main);
new AlertDialog.Builder(this)
.setIcon(R.drawable.icon)
.setTitle("对话框")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
}
}).show();
// AlertDialog.show(this, "This Dialog Demo",
// R.drawable.icon, "That's a file, not a directory", "Cancel", false);
}
}
上面就是一个简单的Dialog的例子,
如果想知道高级的一些用法,可以查看AlertDialog的API相关文档
更多相关文章
- android踩坑日记
- android弹出对话框
- android dialog
- Android]仿通讯录ListView小例子
- 《Android面试宝典》学习笔记(第四章:对话框、信息提示和菜单)
- 地图入门(一):Android上使用Google Maps加标注的最最简单的例子
- Android学习笔记(33):Android对话框
- Android中am命令用法详解
- Android列表控件Spinner简单用法示例