DialogDemo
16lz
2021-01-25
Android开发技巧 对话框例子
luwei - 星期五, 2009/01/09 - 22:47 - 更新- Android开发
这回我们来研究下Android的Dialog的用法。看看难不难用。
跟J2ME 的Alert比起来谁的更容易上手。
package com.gggeye.android;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
/**
* 对话框的例子
*/
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();
}
}
上面就是一个简单的Dialog的例子,
如果想知道高级的一些用法,可以查看AlertDialog的API相关文档.
更多相关文章
- Android(安卓)UI学习 - ListView
- 【攻克Android(安卓)(14)】Dialog 对话框
- Android桌面小组件:最简例子
- 关于Android(安卓)6.0上应用的动态权限授权解决方案!
- android Dialog 例子
- Eclipse3.7中搭建Android开发环境
- Android(安卓)采用工厂类创建对话框
- android中的dailog
- Android游戏引擎《Rokon》学习笔记六:一个使用Box2D的Rokon小例子