`

Android Dialog用法-AlertDialog,ProgressDialog

 
阅读更多

转载http://blog.csdn.net/ameyume/article/details/6138488

摘要: 创建对话框 一个对话框一般是一个出现在当前Activity之上的一个小窗口. 处于下面的Activity失去焦点, 对话框接受所有的用户交互. 对话框一般用于提示信息和与当前应用程序直接相关的小功能.Android API 支持下列类型 ...
创建对话框
  一个对话框一般是一个出现在当前Activity之上的一个小窗口. 处于下面的Activity失去焦点, 对话框接受所有的用户交互. 对话框一般用于提示信息和与当前应用程序直接相关的小功能.
  Android API 支持下列类型的对话框对象:
  警告对话框 AlertDialog:  一个可以有0到3个按钮, 一个单选框或复选框的列表的对话框. 警告对话框可以创建大多数的交互界面, 是推荐的类型.
  进度对话框 ProgressDialog:  显示一个进度环或者一个进度条. 由于它是AlertDialog的扩展, 所以它也支持按钮.
  日期选择对话框 DatePickerDialog:  让用户选择一个日期.
  时间选择对话框 TimePickerDialog:  让用户选择一个时间.
  如果你希望自定义你的对话框, 可以扩展Dialog类.
  Showing a Dialog 显示对话框
  一个对话框总是被创建和显示为一个Activity的一部分. 你应该在Activity的onCreateDialog(int)中创建对话框. 当你使用这个回调函数时,Android系统自动管理每个对话框的状态并将它们和Activity连接, 将Activity变为对话框的"所有者". 这样,每个对话框从Activity继承一些属性. 例如,当一个对话框打开时, MENU键会显示Activity的菜单, 音量键会调整Activity当前使用的音频流的音量.
  注意: 如果你希望在onCreateDialog()方法之外创建对话框, 它将不会依附在Activity上. 你可以使用setOwnerActivity(Activity)来将它依附在Activity上.
  当你希望显示一个对话框时, 调用showDialog(int)并将对话框的id传给它.
  当一个对话框第一次被请求时,Android调用onCreateDialog(int). 这里是你初始化对话框的地方. 这个回调函数传入的id和showDialog(int)相同. 创建对话框之后,将返回被创建的对象.
  在对话框被显示之前,Android还会调用onPrepareDialog(int, Dialog). 如果你希望每次显示对话框时有动态更改的内容, 那么就改写这个函数. 该函数在每次一个对话框打开时都调用. 如果你不定义该函数,则对话框每次打开都是一样的. 该函数也会传入对话框的id以及你在onCreateDialog()中创建的Dialog对象.
  最好的定义onCreateDialog(int) 和onPrepareDialog(int, Dialog) 的方法就是使用一个switch语句来检查传入的id. 每个case创建相应的对话框. 例如, 一个游戏使用两个对话框: 一个来指示游戏暂停,另一个指示游戏结束. 首先, 为它们定义ID:static final int DIALOG_PAUSED_ID = 0;
static final int DIALOG_GAMEOVER_ID = 1;
然后, 在onCreateDialog(int)中加入一个switch语句:
  1. protected Dialog onCreateDialog(int id) {  
  2.     Dialog dialog;  
  3.     switch(id) {  
  4.     case DIALOG_PAUSED_ID:  
  5.         // do the work to define the pause Dialog   
  6.         break;  
  7.     case DIALOG_GAMEOVER_ID:  
  8.         // do the work to define the game over Dialog   
  9.         break;  
  10.     default:  
  11.         dialog = null;  
  12.     }  
  13.     return dialog;  
  14. }   
  注意: 在这个例子中, case语句为空因为定义Dialog的程序在后面会有介绍.
  在需要显示对话框是, 调用showDialog(int), 传入对话框的id:
  showDialog(DIALOG_PAUSED_ID);Dismissing a Dialog 解除对话框
  当你准备关闭对话框时, 你可以使用dismiss()函数. 如果需要的话, 你也可以从Activity调用dismissDialog(int), 二者效果是一样的.
  如果你使用onCreateDialog(int)来管理你的对话框的状态, 那么每次你的对话框被解除时, 该对话框对象的状态会被Activity保存. 如果你决定你不再需要这个对象或者需要清除对话框的状态, 那么你应该调用 removeDialog(int). 这将把所有该对象的内部引用移除, 如果该对话框在显示的话将被解除.
  Using dismiss listeners 使用解除监听器
  如果你希望在对话框解除时运行某些程序, 那么你应该给对话框附加一个解除监听器.
  首先定义DialogInterface.OnDismissListener接口. 这个接口只有一个方法, onDismiss(DialogInterface), 该方法将在对话框解除时被调用.
  然后将你的OnDismissListener实现传给setOnDismissListener().
  然而,注意对话框也可以被"取消". 这是一个特殊的情形, 它意味着对话框被用户显式的取消掉. 这将在用户按下"back"键时, 或者对话框显式的调用cancel()(按下对话框的cancel按钮)时发生. 当一个对话框被取消时, OnDismissListener将仍然被通知, 但如果你希望在对话框被显示取消(而不是正常解除)时被通知, 则你应该使用setOnCancelListener()注册一个DialogInterface.OnCancelListener.
  Creating an AlertDialog 创建警告对话框
  An AlertDialog is an extension of the Dialog class. It is capable of constructing most dialog user interfaces and is the suggested dialog type. You should use it for dialogs that use any of the following features:
  一个警告对话框是对话框的一个扩展. 它能够创建大多数对话框用户界面并且是推荐的对话框类新星. 对于需要下列任何特性的对话框,你都应该使用它:
  一个标题
  一条文字消息
  1个-3个按钮
  一个可选择的列表(单选框或者复选框)
  要创建一个AlertDialog, 使用AlertDialog.Builder子类. 使用AlertDialog.Builder(Context)来得到一个Builder, 然后使用该类的公有方法来定义AlertDialog的属性. 设定好以后, 使用create()方法来获得AlertDialog对象.
  下面的主题展示了如何为AlertDialog定义不同的属性, 使用AlertDialog.Builder类. 如果你使用这些示例代码, 你可以在onCreateDialog()中返回最后的Dialog对象来获得图片中对话框的效果.
  Adding buttons 增加按钮


 
要创建一个如图所示的窗口, 使用set...Button()方法:
  1. AlertDialog.Builder builder = new AlertDialog.Builder(this);  
  2. builder.setMessage("Are you sure you want to exit?")  
  3.        .setCancelable(false)  
  4.        .setPositiveButton("Yes"new DialogInterface.OnClickListener() {  
  5.            public void onClick(DialogInterface dialog, int id) {  
  6.                 MyActivity.this.finish();  
  7.            }  
  8.        })  
  9.        .setNegativeButton("No"new DialogInterface.OnClickListener() {  
  10.            public void onClick(DialogInterface dialog, int id) {  
  11.                 dialog.cancel();  
  12.            }  
  13.        });  
  14. AlertDialog alert = builder.create();  
首先,使用setMessage(CharSequence)为对话框增加一条消息。 然后, 开始连续调用方法, 使用setCancelable(boolean)将对话框设为不可取消(不能使用back键来取消)。对每一个按钮,使用set...Button()方法,该方法接受按钮名称和一个DialogInterface.OnClickListener,该监听器定义了当用户选择该按钮时应做的动作。
  注意:对每种按钮类型,只能为AlertDialog创建一个。也就是说,一个AlertDialog不能有两个以上的"positive"按钮。这使得可能的按钮数量最多为三个:肯定、否定、中性。这些名字和实际功能没有联系,但是将帮助你记忆它们各做什么事情。
Adding a list 增加列表


 
要创建一个具有可选项的AlertDialog,使用setItems()方法:
  1. final CharSequence[] items = {"Red""Green""Blue"};   
  2. AlertDialog.Builder builder = new AlertDialog.Builder(this);  
  3. builder.setTitle("Pick a color");  
  4. builder.setItems(items, new DialogInterface.OnClickListener() {  
  5.     public void onClick(DialogInterface dialog, int item) {  
  6.         Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();  
  7.     }  
  8. });  
  9. AlertDialog alert = builder.create();  
首先增加一个标题。然后使用setItems()增加一个可选列表,该列表接受一个选项名称的列表和一个DialogInterface.OnClickListener, 后者定义了选项对应的响应。

Adding checkboxes and radio buttons 增加单选框和复选框
 

 
要创建一个带有多选列表或者单选列表的对话框, 使用setMultiChoiceItems()和setSingleChoiceItems()方法。如果你在onCreateDialog()中创建可选择列表, Android会自动管理列表的状态. 只要activity仍然活跃, 那么对话框就会记住刚才选中的选项,但当用户退出activity时,该选择丢失。
  注意: 要在你的acitivity离开和暂停时保存选择, 你必须在activity的声明周期中正确的保存和恢复设置。为了永久性保存选择,你必须使用数据存储技术中的一种。
  要创建一个具有单选列表的AlertDialog,只需将一个例子中的setItems()换成 setSingleChoiceItems():
  1. final CharSequence[] items = {"Red""Green""Blue"};   
  2. AlertDialog.Builder builder = new AlertDialog.Builder(this);  
  3. builder.setTitle("Pick a color");  
  4. builder.setSingleChoiceItems(items, -1new DialogInterface.OnClickListener() {  
  5.     public void onClick(DialogInterface dialog, int item) {  
  6.         Toast.makeText(getApplicationContext(), items[item], Toast.LENGTH_SHORT).show();  
  7.     }  
  8. });  
  9. AlertDialog alert = builder.create();  
第二个参数是默认被选中的选项位置,使用“-1”来表示默认情况下不选中任何选项。

Creating a ProgressDialog 创建进度对话框


 
一个ProgressDialog(进度对话框)是AlertDialog的扩展。它可以显示一个进度的动画——进度环或者进度条。这个对话框也可以提供按钮,例如取消一个下载等。
  打开一个进度对话框很简单,只需要调用 ProgressDialog.show()即可。例如,上图的对话框可以不通过onCreateDialog(int),而直接显示:
  ProgressDialog dialog = ProgressDialog.show(MyActivity.this, "",
  "Loading. Please wait...", true);
  第一个参数是应用程序上下文。第二个为对话框的标题(这里为空),第三个为对话框内容, 最后一个为该进度是否为不可确定的(这只跟进度条的创建有关,见下一节)。
  进度对话框的默认样式为一个旋转的环。如果你希望显示进度值,请看下一节。
  Showing a progress bar 显示进度条
  使用一个动画进度条来显示进度:
  使用 ProgressDialog(Context)构造函数来初始化一个ProgressDialog对象。
  将进度样式设置为"STYLE_HORIZONTAL",使用setProgressStyle(int)方法。并且设置其它属性,例如内容等。
  在需要显示时调用show()或者从onCreateDialog(int)回调函数中返回该ProgressDialog。
  你可以使用 setProgress(int)或者incrementProgressBy(int)来增加显示的进度。
  例如,你的设置可能像这样:ProgressDialog progressDialog;
progressDialog = new ProgressDialog(mContext);
progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progressDialog.setMessage("Loading...");
progressDialog.setCancelable(false);
  设置很简单。大部分创建进度对话框需要的代码是在更新它的进程中。你可能需要在一个新的线程中更新它,并使用Handler来将进度报告给Activity。如果你不熟悉使用Handler和另外的线程,请看下列例子,该例子使用了一个新的线程来更新进度。
  Example ProgressDialog with a second thread 例--使用一个线程来显示进度对话框
  这个例子使用一个线程来跟踪一个进程的进度(其实为从1数到100)。每当进度更新时,该线程通过Handler给主activity发送一个消息。主Activity更新ProgressDialog.package com.example.progressdialog;
  1. import android.app.Activity;  
  2. import android.app.Dialog;  
  3. import android.app.ProgressDialog;  
  4. import android.os.Bundle;  
  5. import android.os.Handler;  
  6. import android.os.Message;  
  7. import android.view.View;  
  8. import android.view.View.OnClickListener;  
  9. import android.widget.Button;  
  10. public class NotificationTest extends Activity {  
  11.     static final int PROGRESS_DIALOG = 0;  
  12.     Button button;  
  13.     ProgressThread progressThread;  
  14.     ProgressDialog progressDialog;  
  15.     /** Called when the activity is first created. */  
  16.     public void onCreate(Bundle savedInstanceState) {  
  17.         super.onCreate(savedInstanceState);  
  18.         setContentView(R.layout.main);   
  19.         // Setup the button that starts the progress dialog   
  20.         button = (Button) findViewById(R.id.progressDialog);  
  21.         button.setOnClickListener(new OnClickListener(){  
  22.             public void onClick(View v) {  
  23.                 showDialog(PROGRESS_DIALOG);  
  24.             }  
  25.         });  
  26.     }  
  27.     protected Dialog onCreateDialog(int id) {  
  28.         switch(id) {  
  29.         case PROGRESS_DIALOG:  
  30.             progressDialog = new ProgressDialog(NotificationTest.this);  
  31.             progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);  
  32.             progressDialog.setMessage("Loading...");  
  33.             progressThread = new ProgressThread(handler);  
  34.             progressThread.start();  
  35.             return progressDialog;  
  36.         default:  
  37.             return null;  
  38.         }  
  39.     }   
  40.     // Define the Handler that receives messages from the thread and update the progress   
  41.     final Handler handler = new Handler() {  
  42.         public void handleMessage(Message msg) {  
  43.             int total = msg.getData().getInt("total");  
  44.             progressDialog.setProgress(total);  
  45.             if (total >= 100){  
  46.                 dismissDialog(PROGRESS_DIALOG);  
  47.                 progressThread.setState(ProgressThread.STATE_DONE);  
  48.             }  
  49.         }  
  50.     };   
  51.     /** Nested class that performs progress calculations (counting) */  
  52.     private class ProgressThread extends Thread {  
  53.         Handler mHandler;  
  54.         final static int STATE_DONE = 0;  
  55.         final static int STATE_RUNNING = 1;  
  56.         int mState;  
  57.         int total;  
  58.         ProgressThread(Handler h) {  
  59.             mHandler = h;  
  60.         }  
  61.         public void run() {  
  62.             mState = STATE_RUNNING;     
  63.             total = 0;  
  64.             while (mState == STATE_RUNNING) {  
  65.                 try {  
  66.                     Thread.sleep(100);  
  67.                 } catch (InterruptedException e) {  
  68.                     Log.e("ERROR""Thread Interrupted");  
  69.                 }  
  70.                 Message msg = mHandler.obtainMessage();  
  71.                 Bundle b = new Bundle();  
  72.                 b.putInt("total", total);  
  73.                 msg.setData(b);  
  74.                 mHandler.sendMessage(msg);  
  75.                 total++;  
  76.             }  
  77.         }  
  78.         /* sets the current state for the thread, 
  79.          * used to stop the thread */  
  80.         public void setState(int state) {  
  81.             mState = state;  
  82.         }  
  83.     }  
  84. }  
Creating a Custom Dialog 创建自定义对话框


 
如果你想自定义一个对话框,你可以使用布局元素来创造你的对话框的布局。定义好布局后,将根View对象或者布局资源ID传给setContentView(View).
例如,创建如图所示的对话框:
创建一个xml布局custom_dialog.xml:
  1. http://schemas.android.com/apk/res/android"  
  2.               android:id="@+id/layout_root"  
  3.               android:orientation="horizontal"  
  4.               android:layout_width="fill_parent"  
  5.               android:layout_height="fill_parent"  
  6.               android:padding="10dp"  
  7.               >  
  8.                    android:layout_width="wrap_content"  
  9.                android:layout_height="fill_parent"  
  10.                android:layout_marginRight="10dp"  
  11.                />  
  12.                   android:layout_width="wrap_content"  
  13.               android:layout_height="fill_parent"  
  14.               android:textColor="#FFF"  
  15.               />  
该xml定义了一个LinearLayout中的一个ImageView 和一个TextView。
将以上布局设为对话框的content view,并且定义ImageView 和 TextView的内容:
  1. Context mContext = getApplicationContext();  
  2. Dialog dialog = new Dialog(mContext);   
  3. dialog.setContentView(R.layout.custom_dialog);  
  4. dialog.setTitle("Custom Dialog");  
  5. TextView text = (TextView) dialog.findViewById(R.id.text);  
  6. text.setText("Hello, this is a custom dialog!");  
  7. ImageView image = (ImageView) dialog.findViewById(R.id.image);  
  8. image.setImageResource(R.drawable.android);  
在初始化Dialog之后,使用setContentView(int),将布局资源id传给它。现在Dialog有一个定义好的布局,你可以使用findViewById(int)来找到该元素的id并修改它的内容。
  使用前面所讲的方法显示对话框。
  一个使用Dialog类建立的对话框必须有一个标题。如果你不调用setTitle(),那么标题区域会保留空白。如果你不希望有一个标题,那么你应该使用AlertDialog类来创建自定义对话框。然而,由于一个AlertDialog使用AlertDialog.Builder类来建立最方便,所以你没有方法使用setContentView(int),而是只能使用setView(View)。该方法接受一个View对象,所以你需要从xml中展开你的根View。
  要展开一个xml布局,使用 getLayoutInflater() (或 getSystemService())取得LayoutInflater,然后调用inflate(int, ViewGroup),第一个参数为布局id,而第二个参数为根view的id。现在,你可以使用展开后的布局来找到View对象并定义ImageView和TextView元素的内容。然后实例化AlertDialog.Builder并使用setView(View)来为对话框设置展开后的布局。例如:
  1. AlertDialog.Builder builder;  
  2. AlertDialog alertDialog;   
  3. Context mContext = getApplicationContext();  
  4. LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);  
  5. View layout = inflater.inflate(R.layout.custom_dialog,  
  6.                                (ViewGroup) findViewById(R.id.layout_root));  
  7. TextView text = (TextView) layout.findViewById(R.id.text);  
  8. text.setText("Hello, this is a custom dialog!");  
  9. ImageView image = (ImageView) layout.findViewById(R.id.image);  
  10. image.setImageResource(R.drawable.android);  
  11. builder = new AlertDialog.Builder(mContext);  
  12. builder.setView(layout);  
  13. alertDialog = builder.create();  
使用AlertDialog来自定义对话框,可以利用其内置特性例如按钮、选择列表、标题、图标等。
实例见附件:
LayoutInflater
般来讲,我们用LayoutInflater做一件事:inflate。inflate这个方法总共有四种形式,目的都是把xml表述的layout转化为View。This class is used to instantiate layout XML file into its corresponding View objects . It is never be used directly -- use getLayoutInflater() or getSystemService(String)getLayoutInflater() or getSystemService(String) to retrieve a standard LayoutInflater instance that is already hooked up to the current context and correctly configured for the device you are running on


1. Context.public abstract Object getSystemService (String name) Return the handle to a system-level service by name. The class of the returned object varies by the requested name. 具体参见文档。

 

2. 2种获得LayoutInflater的方法

(1)通过SystemService获得

LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

(2)从给定的context中获取

 



 

(3)二者区别:实质是一样的,请看源码

Java代码 复制代码 
  1. public static LayoutInflater from(Context context) {   
  2.     LayoutInflater LayoutInflater =   
  3.             (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);   
  4.     if (LayoutInflater == null) {   
  5.         throw new AssertionError("LayoutInflater not found.");   
  6.     }   
  7.     return LayoutInflater;   
  8. }   

3. LayoutInflater.inflate()

将Layout文件转换为View,顾名思义,专门供Layout使用的Inflater。虽然Layout也是View的子类,但在android中如果想将xml中的Layout转换为View放入.java代码中操作,只能通过Inflater,而不能通过findViewById(),这一段描述有误,看如下代码 。看下面文档写的已经很清楚。

 

Xml代码 复制代码 
  1. <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     android:orientation="vertical"    
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="wrap_content">  
  5.        
  6.     <LinearLayout android:id="@+id/placeslist_linearlayout"  
  7.         android:layout_width="fill_parent"  
  8.         android:layout_height="wrap_content"  
  9.         android:orientation="vertical">  
  10.            
  11.     </LinearLayout>      
  12. </ScrollView>  

 LinearLayout linearLayout = (LinearLayout) findViewById(R.id.placeslist_linearlayout);

linearLayout.addView(place_type_text);

这是可运行的,这上面的xml中,LinearLayout不再是Layout的代表,而只是一个普通的View。

 

 

 



  

4. findViewById有2中形式

R.layout.xx 是引用res/layout/xx.xml的布局文件(inflate方法),R.id.xx是引用布局文件里面的组件,组件的id是xx...(findViewById方法)。看看R.java配置文件吧,R对文件分类管理,多写几个layout.xml后你会发现,所有的组件id都能用R.id.xx来查看,但是组件不在setContentView()里面的layout中就无法使用,Activity.findViewById()会出现空指针异常

(1)Activity中的findViewById()

 



 (2)View中的findViewById()



 

 

5.

 

  • 大小: 3.6 KB
  • 大小: 3.7 KB
  • 大小: 5 KB
  • 大小: 2.6 KB
  • 大小: 3.9 KB
  • 大小: 6.1 KB
  • 大小: 22.3 KB
  • 大小: 10.4 KB
  • 大小: 12.4 KB
分享到:
评论

相关推荐

    Dialog对话框的使用 (progressDialog、AlertDialog、点击不消失、进度条)

    Dialog对话框的使用 (progressDialog、AlertDialog、点击不消失、进度条) 具体可参考我文章:https://blog.csdn.net/qq_28056277/article/details/84591086 【更新--&gt;下载所需积分太高,更改为固定分值了】

    android Dialog

    代码包含了四种最常用的dialog,有AlertDialog progressDialog,自定义view的dialog,底部弹出式的dialog。 通过设置dialog的style的方式给dialog添加显示动画和消失动画。 代码精简易懂,每句重点的代码都有相应的...

    dialog 汇总小demo

    android dialog 包括alertdialog 和progressdialog 还有自定义通过window 显示的界面很美观。

    Android自定义Dialog

    Android自定义AlertDialog和ProgressDialog。

    Android Dialog详解及实例代码

    AlertDialog.Builder dialog = new AlertDialog.Builder(this); dialog.setTitle(选择对话框); dialog.setMessage(请选择确认或取消); dialog.setCancelable(false); //设置按下返回键不能消失 dialog....

    Android ProgressDialog使用总结

    ProgressDialog 继承自AlertDialog,AlertDialog继承自Dialog,实现DialogInterface接口。 ProgressDialog的创建方式有两种,一种是new Dialog ,一种是调用Dialog的静态方法Dialog.show()。 // 方式一:new Dialog ...

    Android编程自定义Dialog的方法分析

    android 提供给我们的只有2种Dialog 即 AlertDialog & ProgressDialog 但是 Dialog 有其自身的特点:1. 不是 Activity 2. 开销比 Activity 小得多 鉴于以上的优点 我们就有定制自己Dialog 的需求 原理: 1. android...

    Android ProgressDialog用法之实现app上传文件进度条转圈效果

    ProgressDialog 继承自AlertDialog,AlertDialog继承自Dialog public class ProgressDialog extends AlertDialog ProgressDialog的创建方式有两种,一种是new ProgressDialog,一种是调用ProgressDialog的静态...

    Android Dialog 对话框详解及示例代码

    Android Dialog 对话框 1、Dialog介绍 2、AlertDialog的基本使用 3、自定义对话框 Custom Dialog 一、Dialog介绍 Dialog也是Android中常用的用户界面元素,他同Menu一样也不是View的子类。让我们看一下它的...

    andorid dialog 大合集

    AlertDialog.Builder builder = new AlertDialog.Builder(MainDialog.this); switch(id) { case DIALOG_0: builder.setIcon(R.drawable.icon); builder.setTitle("你确定要离开吗?"); builder....

    简析Android多种AlertDialog对话框效果

    android提供了四类常用的对话框,本文分享具体实现方法: 1.AlertDialog,功能最丰富,实际运用最广泛 2.progressDialog,进度条对话框 3.DatePickerDialog,日期选择对话框 4.TimePickerDialog,时间选择...

    安卓开发对话框大全

    import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.DatePickerDialog; import android.app.DatePickerDialog.OnDateSetListener; import android.app.ProgressDialog; ...

    android 中ProgressDialog实现全屏效果的示例

    ProgressDialog 继承自AlertDialog,AlertDialog继承自Dialog,实现DialogInterface接口。 ProgressDialog的创建方式有两种,一种是new Dialog ,一种是调用Dialog的静态方法Dialog.show()。 // 方式一:new Dialog ...

    Android 对话框 Dialog使用实例讲解

    对话框 Dialog 什么是对话框 对话框是在当前的页面之上弹出的小窗口, 用于显示一些重要的提示信息, 提示用户的输入,确认信息,或显示某种状态.如 : 显示进度条对话框, 退出提示. 对话框的特点: 1, 当前界面弹出的小...

    Android中几个基本的对话框

    Android中基本Dialog对话框基本对话框介绍1.普通对话框2.单选对话框3.复选对话框4.自定义message对话框5.水平进度对话框6.日期对话框7.时间对话框8.用户自定义对话框 基本对话框介绍 对话框 用法 普通 ...

    Android程序设计课程报告.doc

    builder.setIcon(android.R.drawable.ic_dialog_info); builder.setTitle("升级提醒"); builder.setMessage(info.getDescription()); builder.setCancelable(false); builder.setPositiveButton("确定", new ...

    Android典型技术模块开发详解

    3.3 基本用法 3.3.1 创建Activity 3.3.2 启动Activity 3.3.3 窗口Activity 3.3.4 Activity生命周期验证 3.4 Activity之间通信 3.4.1 Activity传递一般类型 3.4.2 Activity传递对象类型 3.4.2 Activity回传数据 3.5 ...

    DialogX::speech_balloon:DialogX内置组件库,更方便易用,可自定义程度更高,扩展性更强,轻松实现各种方式,菜单和提示效果,可以使用iOS,MIUI等主题扩展可选

    DialogX的特性: DialogX采用全新的实现方式,不依赖AlertDialog,Window或Fragment实现,更轻便快捷。 DialogX的启动与线程无关,你可以在任意线程启动DialogX而它都将自动在UI线程运行。 DialogX的启动不需要上...

Global site tag (gtag.js) - Google Analytics