首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

AlertDialog 运用 扩展

2012-06-26 
AlertDialog 使用 扩展AlertDialog??[功能]也是一种Dialog??[原理]1. AlertDialog 本身并没有构造函数 即

AlertDialog 使用 扩展

AlertDialog

?

?

[功能]

也是一种Dialog

?

?

[原理]

1. AlertDialog 本身并没有构造函数 即 不可以通过 new AlertDialog(...) 来初始化 而只能通过 AlertDialog.Builder

2. 而 AlertDialog.Builder 比较像是AlertDialog的构造器 用于接收各种和 AlertDialog 有关的参数 然后通过 create() 来创建目标 AlertDialog

?

[代码 步骤]

1. 定义 AlertDialog.Builder 实例 并接受一些参数 如:图片 标题 正文

?AlertDialog 运用 扩展
    ?AlertDialog 运用 扩展
      ?AlertDialog 运用 扩展
        ?AlertDialog 运用 扩展
          ?AlertDialog 运用 扩展

            ?

            ?

            ?

            5. 以上所采用的都是AlertDialog 系统默认的布局 现在说自定义布局的情况 并添加一个用于取消AlertDialog 的 Button

            ?

            * 定义其布局 hello.main

            ?AlertDialog 运用 扩展

              ?

              ?

              * 通过LayoutInflater 得到上面 hello.xml 布局的 View view

              ?AlertDialog 运用 扩展
                ?AlertDialog 运用 扩展
                  ?AlertDialog 运用 扩展
                    ?AlertDialog 运用 扩展
                      ?AlertDialog 运用 扩展

热点排行