Chinaunix首页 | 论坛 | 博客
  • 博客访问: 15505
  • 博文数量: 7
  • 博客积分: 204
  • 博客等级: 入伍新兵
  • 技术积分: 80
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-22 13:26
文章分类

全部博文(7)

文章存档

2011年(7)

我的朋友
最近访客

分类: 嵌入式

2011-03-17 21:10:53

  1. 1、AlertDialog创建流程:
      1.      先是创建AlertDialog.Builder对象,然后设置此对象,最后调用create()方法创建AlertDialog
  2. 2、AlertDialog.Builder的方法:
  • setIcon
  • setTitle
  • setPositiveButton
  • setNeutralButton
  • setNegativeButton
  • setMessage
  • setItems
  • setSingleChoiceItems
  • setMultiChoiceItems
之上这四个,同一个Builder只能调用一次,不可以共存
  1. public create ()

    Creates a with the arguments supplied to this builder. It does not the dialog. This allows the user to do any extra processing before displaying the dialog. Use if you don't have any other processing to do and want this to be created and displayed.

  2. 创建完AlertDialog后是不显示的,要想显示需再调用

  3. 3、举例:
      1. new AlertDialog.Builder(AlertDialogSamples.this)
      2.                 .setIcon(R.drawable.ic_popup_reminder)
      3.                 .setTitle(R.string.alert_dialog_multi_choice)
      4.                 .setMultiChoiceItems(R.array.select_dialog_items3,
      5.                         new boolean[]{false, true, false, true, false, false, false},
      6.                         new DialogInterface.OnMultiChoiceClickListener() {
      7.                             public void onClick(DialogInterface dialog, int whichButton,
      8.                                     boolean isChecked) {

      9.                                 /* User clicked on a check box do some stuff */
      10.                             }
      11.                         })
      12.                 .setPositiveButton(R.string.alert_dialog_ok,
      13.                         new DialogInterface.OnClickListener() {
      14.                     public void onClick(DialogInterface dialog, int whichButton) {

      15.                         /* User clicked Yes so do some stuff */
      16.                     }
      17.                 })
      18.                 .setNegativeButton(R.string.alert_dialog_cancel,
      19.                         new DialogInterface.OnClickListener() {
      20.                     public void onClick(DialogInterface dialog, int whichButton) {

      21.                         /* User clicked No so do some stuff */
      22.                     }
      23.                 })
      24.                .create();
                  
阅读(1073) | 评论(0) | 转发(0) |
0

上一篇:跟Dialog干上了

下一篇:再读NotePad

给主人留下些什么吧!~~