提示框&对话框
来源:互联网 发布:python io模块 编辑:程序博客网 时间:2024/06/05 17:23
提示框:
new AlertDialog.Builder(LoginActivity.this).setTitle("错误")
.setMessage("帐号或密码不能空").setPositiveButton("确定", null)
.show();
------------------------------------------------------------------------------------------------------------------------------------------
对话框:
AlertDialog.Builder ad = new AlertDialog.Builder(
当前类名.this);
//对话框标题
ad.setTitle("选项");
//对话框内容
ad.setMessage("");
String[] string = { "北京", "天津", "上海", "重庆", "澳门", "钓鱼岛", "厦门" };
builder.setItems(string, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
}
// 显示对话框
ad.show();
//对话框选择项(确定、取消...)
//左选项
ad.setPositiveButton("确认",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
}
});
//右选项
ad.setNegativeButton("官方网站",
new DialogInterface.OnClickListener() {
// 显示官方网站按钮,点击打开浏览器,转向www.pocketdigi.com
@Override
public void onClick(DialogInterface dialog, int i) {
Uri uri = Uri
.parse("http://www.pocketdigi.com");
Intent intent = new Intent(Intent.ACTION_VIEW,
uri);
startActivity(intent);
}
});
//内部类
class itemListonClick implements
android.content.DialogInterface.OnClickListener {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
//当选择case 0时
break;
case 1:
//当选择case 1时
break;
}
}
}
***********************************************************************
等待对话框
ProgressDialog.show(MainActivity.this, "请等待", "马上开始");
进度条:
prog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
-------------------------------------------------------------------------------
可关闭对话框:builder.dismiss();
AlertDialog builder = new AlertDialog.Builder(
MainActivity.this).create();
重写返回监听事件:
builder.setOnKeyListener(new DialogInterface.OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode,
KeyEvent event) {
return true;
}
});
设置对话框外不可点击:
builder.setCanceledOnTouchOutside(false);
0 0
- artDialog提示框、对话框
- 提示框&对话框
- SWT 消息提示框 对话框
- 消息提示框和对话框
- android对话框和提示框
- 提示框 选择对话框 等待框
- css实现对话框-带箭头提示框
- Android消息提示框和对话框
- Android消息提示框和对话框
- AlertDialog 提示框 | ProgressDialog 进度对话框
- JOptionPane java 弹出对话框 消息提示框
- 弹出一个提示对话框
- 对话框CToolBarCtrl添加提示
- ajax+提示对话框
- 弹出提示对话框
- 提示对话框(MessageBox)
- 信息提示对话框
- 创建提示对话框
- Ubuntu下安装软件的几种方式
- 关于STL的一些写法
- "Fragment"-Android面试必问"精华技能点"汇总
- 皮划艇找瓶子--------阿里巴巴2015校招研发在线
- Summer day 1
- 提示框&对话框
- iostat命令使用指南
- 内核管理实战之虚地址转换为物理地址
- android app 默认的crash处理流程 (FATAL EXCEPTION)
- 自定义控件
- Bitmap
- 【js学习笔记-036】--属性的特性
- Opencv图像识别从零到精通(3)———单图像显示和多图像显示
- Codeforces Round #337 (Div. 2) 610A(水)