使用大全

public class MainActivity extends ListActivity );
                    pd.setProgress(i);//改变当前进度。可以在子线程中改变进度条的进度。
                }
                pd.dismiss();//当进度为100%时关闭对话框
                //仅为了演示Toast才这么搞!
                Looper.prepare();
                Toast.makeText(context, "加载完毕", Toast.LENGTH_SHORT).show();
                Looper.loop();
            };
        }.start();
    }

}


自定义Dialog的布局1

<?xml version="1.0" encoding="utf-8"?>
<!-- 注意:不同主题下显示效果大不相同 -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="180dp"
    android:layout_height="400dp"
    android:background="@android:color/holo_blue_light"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />
    <EditText
        android:id="@+id/et_username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <EditText
        android:id="@+id/et_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:inputType="textPassword" />

</LinearLayout>


自定义Dialog的布局2

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_blue_light"
    android:gravity="center_horizontal"
    android:orientation="vertical" >
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />
    <EditText
        android:id="@+id/et_username"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />
    <EditText
        android:id="@+id/et_password"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="4dp"
        android:inputType="textPassword" />

</LinearLayout>


Dialog相关API

public class Dialog implements DialogInterface, Window.Callback, KeyEvent.Callback, View.OnCreateContextMenuListener
     
AlertDialog是Dialog的一个直接子类
public class AlertDialog extends Dialog implements android.content.DialogInterface
  
一个AlertDialog可以有两个以上的Button,可以对一个AlertDialog设置相应的信息,比如title、massage等等。
不能直接通过AlertDialog的构造函数来生产一个AlertDialog(AlertDialog所有的构造方法都是protected),只能通过AlertDialog的静态内部类Builder来创建。
public static class Builder
相比Dialog(基本没有什么set方法),AlertDialog使用起来相当方便,几行代码就可以搞定。

附件列表

原生对话框【Dialog】AlertDialog和.Builder的更多相关文章

  1. android中常见对话框之一AlertDialog

    在Android应用中,有多种对话框:Dialog.AlertDialog.ProgressDialog.时间.日期等对话框. (1)Dialog类,是一切对话框的基类,需要注意的是,Dialog类虽 ...

  2. Android 对话框(Dialog)大全 建立你自己的对话框

    Android 对话框(Dialog)大全 建立你自己的对话框 原文地址: http://www.cnblogs.com/salam/archive/2010/11/15/1877512.html A ...

  3. 转 Android 对话框(Dialog)大全 建立你自己的对话框

    Activities提供了一种方便管理的创建.保存.回复的对话框机制,例如 onCreateDialog(int), onPrepareDialog(int, Dialog), showDialog( ...

  4. Android Dialog AlertDialog

    1.普通的对话框 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" andro ...

  5. Android 常用对话框Dialog封装

    Android 6种 常用对话框Dialog封装 包括: 消息对话框.警示(含确认.取消)对话框.单选对话框. 复选对话框.列表对话框.自定义视图(含确认.取消)对话框 分别如下图所示:       ...

  6. Android项目实战(三十二):圆角对话框Dialog

    前言: 项目中多处用到对话框,用系统对话框太难看,就自己写一个自定义对话框. 对话框包括:1.圆角 2.app图标 , 提示文本,关闭对话框的"确定"按钮 难点:1.对话框边框圆角 ...

  7. Android 对话框(Dialog)大全

    转自: http://www.cnblogs.com/salam/archive/2010/11/15/1877512.html Activities提供了一种方便管理的创建.保存.回复的对话框机制, ...

  8. Android 对话框(Dialog)

    Activities提供了一种方便管理的创建.保存.回复的对话框机制,例如 onCreateDialog(int), onPrepareDialog(int, Dialog), showDialog( ...

  9. Android 对话框(Dialog) 及 自己定义Dialog

    Activities提供了一种方便管理的创建.保存.回复的对话框机制,比如 onCreateDialog(int), onPrepareDialog(int, Dialog), showDialog( ...

  10. (转载)Android项目实战(三十二):圆角对话框Dialog

    Android项目实战(三十二):圆角对话框Dialog   前言: 项目中多处用到对话框,用系统对话框太难看,就自己写一个自定义对话框. 对话框包括:1.圆角 2.app图标 , 提示文本,关闭对话 ...

随机推荐

  1. loadrunner中并发数与迭代的区别

    你的理解的虚拟用户应该是 迭代次数 ,录制脚本时只会有1个虚拟用户,1个虚拟用户可以有多次 迭代,也就是 重复执行 Action里面的内容,在场景设置的时候,如果你说的10时在runtime-sett ...

  2. 洛谷P3402 【模板】可持久化并查集 [主席树,并查集]

    题目传送门 可持久化并查集 n个集合 m个操作 操作: 1 a b 合并a,b所在集合 2 k 回到第k次操作之后的状态(查询算作操作) 3 a b 询问a,b是否属于同一集合,是则输出1否则输出0 ...

  3. Struts2 MVC基础介绍

    流程介绍 我们模拟一个请求/响应的情景,来介绍Struts的工作流程.注意,下面的序号和图中的序号没有严格的对应关系. 浏览器向系统发出请求,请求的地址是ac.action 请求被StrutsPrep ...

  4. 【数学】At Coder 091 D题

    [深夜题解] 题目链接:https://arc091.contest.atcoder.jp/tasks/arc091_b 题目大意:给出两个正整数N.K,找出所有的不大于N的正整数对(a,b)使b%a ...

  5. Selenium之PhantomJS相关设置

    设置PhantomJS请求头 默认情况下: from selenium import webdriver import time driver = webdriver.PhantomJS() driv ...

  6. 让你的chrome开发工具console支持jquery

    首先执行以下代码: ;(function(d,s){d.body.appendChild(s=d.createElement('script')).src='http://code.jquery.co ...

  7. bzoj 1045

    确定初始状态(n与1直接谁给了谁几个),后面的就确定了,再根据总结出来的东西决定前面谁给谁几个最优. n=1000000!!! /*********************************** ...

  8. c# -- Form1_Load()不被执行的三个解决方法

    我的第一个c#练习程序,果然又出现问题了...在Form1_Load() not work.估计我的人品又出现问题了. 下面实现的功能很简单,就是声明一个label1然后,把它初始化赋值为hello, ...

  9. ACM -- 算法小结(一)利用数组存放实现排序

    利用数组存放实现排序    hodj1425   321MS   2011/08 题意:输入n个数字,要求输出从大到小排序的前m个数 解题技巧:利用大数存储在数组后面,小数存储在前面,倒序输出完成从大 ...

  10. UESTC 2015dp专题 F 邱老师看电影 概率dp

    邱老师看电影 Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/contest/show/65 Descr ...