Android——Dialog
public class DialogActivity extends Activity {
//进度对话框
ProgressDialog progressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Dialog dialog = new AlertDialog.Builder(DialogActivity.this)
.setTitle("登录提示")
// 设置标题
.setMessage("这里需要登录!")
// 设置内容
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
// 点击确定转向登录框
LayoutInflater layoutInflater = LayoutInflater
.from(DialogActivity.this);
// 得到自定义对话框
final View dialogView = layoutInflater.inflate(
R.layout.dialog_login, null);
// 创建对话框
AlertDialog dlg = new AlertDialog.Builder(
DialogActivity.this).setTitle("登录框")
.setView(dialogView)
// 设置自定义对话框的的样式
.setPositiveButton("确定",// 设置确定按钮
new DialogInterface.OnClickListener() {// 设置确定按钮事件监听
@Override
public void onClick(
DialogInterface dialog,
int whichButton) {
// 输入完成,点击确定按钮开始登录,显示进度对话框
progressDialog = ProgressDialog
.show(DialogActivity.this,
"请等待……",
"正在为你登录……",
true);
new Thread() {
public void run() {
try {
sleep(3000);
} catch (Exception e) {
e.printStackTrace();
} finally {
// 登录结束,取消进度对话框
progressDialog
.dismiss();
DialogActivity.this.finish();//<自己加的>
}
}
}.start();
}
}).setNegativeButton("取消",// 设置取消按钮
new DialogInterface.OnClickListener() {
@Override
public void onClick(
DialogInterface dialog,
int whichButton) {
// 点击取消按钮退出应用程序
DialogActivity.this.finish();
}
}).create();
dlg.show();
}
})
.setNeutralButton("退出", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int whichButton) {
// 点击退出按钮,退出应用程序
DialogActivity.this.finish();
}
}).create();// 创建按钮
// 显示对话框
dialog.show();
}
}
Android——Dialog的更多相关文章
- Android Dialog使用举例
在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择.这些功能我们叫它Android Dialog对话框,在我们使用Android的过程中,我归纳了一 ...
- Android Dialog 创建上下文菜单
Android Dialog中的listview创建上下文菜单 listView.setOnCreateContextMenuListener(new OnCreateContextMenuListe ...
- Android控件——7种形式的Android Dialog使用举例(转载)
在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择.这些功能我们叫它Android Dialog对话框,在我们使用Android的过程中,我归纳了一 ...
- Android Dialog对话框的七种形式的使用
参考资料:http://www.oschina.net/question/54100_32486 注:代码进行了整理 在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询 ...
- 8种形式的Android Dialog使用举例
在Android开发中,我们经常会需要在Android界面上弹出一些对话框,比如询问用户或者让用户选择.这些功能我们叫它Android Dialog对话框,在我们使用Android的过程中,我归纳了一 ...
- android Dialog实例
Dialog类 public class DialogUtil { public static Dialog EditDialog(Activity context,View view){ final ...
- android dialog
/** * @Title MenuTest.java * @package com.example.standardview * @since * @version 1.0.0 * @author V ...
- android dialog 有关token的问题
android中的dialog显示一般是显示在宿主context里面,但context有几种模式,我今天遇到问题就是在BroadcastReceiver广播里面构造对话框后显示出现的问题:androi ...
- android dialog 模拟新浪、腾讯title弹框效果
http://blog.csdn.net/jj120522/article/details/7764183 首先我们看一下新浪微博的效果(其它就是一个dialog): 点 ...
- Android Dialog用法
摘要: 创建对话框 一个对话框一般是一个出现在当前Activity之上的一个小窗口. 处于下面的Activity失去焦点, 对话框接受所有的用户交互. 对话框一般用于提示信息和与当前应用程序直接相关的 ...
随机推荐
- [MVC] 深入浅出Spring MVC
[MVC] 深入浅出Spring MVC 转:http://4925054.blog.51cto.com/4915054/1176855 Spring MVC主要包括以下要点: 1:由Dispatch ...
- Windows命令行查看文件的MD5
certutil -hashfile D:\apache-tomcat-7.0.68-windows-x64.zip MD5certutil -hashfile D:\apache-tomcat-7 ...
- Networking in too much detail
The players This document describes the architecture that results from a particular OpenStack config ...
- can't run as root without the -u switch
[root@localhost ~]# /usr/local/memcache/bin/memcached can't run as root without the -u switch [root@ ...
- string和stringBuilder区别
C# String 对象是不可改变的.每次使用 System.String 类中的方法之一时,都要在内存中创建一个新的字符串对象,这就需要为该新对象分配新的空间.在需要对字符串执行重复修改的情况下,与 ...
- sql server 2012 如何收缩事务日志
sql2008不再支持 BACKUP LOG 数据库名 WITH NO_LOG 语句 BACKUP Log zxta with no_log 截断事务日志 sql2008 提示错误如下 BACKU ...
- 3. c的输入输出
putchar与getchar操作输入输出通道 #include <stdio.h> #include <ctype.h> main(){ int c; while((c = ...
- (C/C++) Callback Function 回调(diao)函数
原文: http://www.codeguru.com/cpp/cpp/cpp_mfc/callbacks/article.php/c10557/Callback-Functions-Tutorial ...
- Firmware综述
软件的层次关系(从底层到高层)如下: 1. PSP (Processor Support Package). A group of file that are specific to a CPU ty ...
- POJ 1410 Intersection(计算几何)
题目大意:题目意思很简单,就是说有一个矩阵是实心的,给出一条线段,问线段和矩阵是否相交解题思路:用到了线段与线段是否交叉,然后再判断线段是否在矩阵里面,这里要注意的是,他给出的矩阵的坐标明显不是左上和 ...