使用大全

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使用起来相当方便,几行代码就可以搞定。

附件列表

最新文章

  1. 【Git学习笔记】初始化Git仓库和版本回退
  2. phpStudy 创建多个站点,绑定域名
  3. Js设置及获取Cookie的方法
  4. C++11中对类(class)新增的特性
  5. SparkSQL项目中的应用
  6. django-CSRF verification failed. Request aborted
  7. 解决Maven默认仓库没有的jar下载(二)
  8. 在WinForm中使用Web Service来实现软件自动升级
  9. SetWindowLong
  10. Python装饰器主要用法
  11. Cocos2D中Action的进阶使用技巧(二)
  12. config.go 源码阅读
  13. c/c++再学习:常用字符串转数字操作
  14. 三、Python-列表
  15. 63.1拓展之纯 CSS 创作一个摇摇晃晃的 loader
  16. 负数字符串经过int处理之后还是负数
  17. Android笔记:intent
  18. SpringMVC框架08——统一异常处理
  19. 基于VUE的SPA单页应用开发-加载性能篇
  20. 第二百九十四节,Redis缓存-Redis安装

热门文章

  1. 查找无序数组中第K大的数
  2. 《java虚拟机》----java内存区域与内存溢出异常
  3. scrapy抓取拉勾网职位信息(五)——代码优化
  4. SpringBoot 热部署 和 热加载
  5. AM335x内核模块驱动之LED
  6. Number 和 parseInt 区别
  7. 如何配置FastReport.Net环境
  8. Every-SG 博弈论 mark定义和结论
  9. 【BIT套主席树】COGS257-动态排名系统
  10. bzoj 3685: 普通van Emde Boas树