<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      Android下的對(duì)話框

      layout文件

       

       1 <?xml version="1.0" encoding="utf-8"?>
       2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
       3     android:layout_width="fill_parent"
       4     android:layout_height="fill_parent"
       5     android:orientation="vertical" >
       6 
       7     <Button
       8         android:layout_width="fill_parent"
       9         android:layout_height="wrap_content"
      10         android:onClick="click0"
      11         android:text="開啟對(duì)話框activities" />
      12 
      13     <Button
      14         android:layout_width="fill_parent"
      15         android:layout_height="wrap_content"
      16         android:onClick="click1"
      17         android:text="顯示通知對(duì)話框" />
      18 
      19     <Button
      20         android:layout_width="fill_parent"
      21         android:layout_height="wrap_content"
      22         android:onClick="click2"
      23         android:text="顯示單選對(duì)話框" />
      24 
      25     <Button
      26         android:layout_width="fill_parent"
      27         android:layout_height="wrap_content"
      28         android:onClick="click3"
      29         android:text="顯示帶按鈕的單選對(duì)話框" />
      30 
      31     <Button
      32         android:layout_width="fill_parent"
      33         android:layout_height="wrap_content"
      34         android:onClick="click4"
      35         android:text="顯示帶按鈕的多選對(duì)話框" />
      36     <Button
      37         android:layout_width="fill_parent"
      38         android:layout_height="wrap_content"
      39         android:onClick="click5"
      40         android:text="進(jìn)度條對(duì)話框" />
      41       <Button
      42         android:layout_width="fill_parent"
      43         android:layout_height="wrap_content"
      44         android:onClick="click6"
      45         android:text="進(jìn)度條對(duì)話框顯示具體進(jìn)度" />
      46 </LinearLayout>

      Activity
      DemoActivity.java

        1 package cn.itcast.dialog;
        2 
        3 import android.app.Activity;
        4 import android.app.AlertDialog;
        5 import android.app.AlertDialog.Builder;
        6 import android.app.ProgressDialog;
        7 import android.content.DialogInterface;
        8 import android.content.DialogInterface.OnClickListener;
        9 import android.content.DialogInterface.OnMultiChoiceClickListener;
       10 import android.content.Intent;
       11 import android.net.Uri;
       12 import android.os.Bundle;
       13 import android.view.View;
       14 import android.widget.Toast;
       15 
       16 public class DemoActivity extends Activity {
       17     @Override
       18     public void onCreate(Bundle savedInstanceState) {
       19         super.onCreate(savedInstanceState);
       20         setContentView(R.layout.main);
       21     }
       22 
       23     // 當(dāng)當(dāng)前的activity失去焦點(diǎn)的時(shí)候調(diào)用的方法.
       24     @Override
       25     protected void onPause() {
       26         // 對(duì)話框 是activity的一部分,彈出對(duì)話框 不會(huì)讓activity失去焦點(diǎn).
       27         System.out.println("失去焦點(diǎn)");
       28         super.onPause();
       29     }
       30 
       31     public void click0(View view) {
       32         Intent intent = new Intent(this, DialogActivity.class);
       33         startActivity(intent);
       34     }
       35 
       36     public void click1(View view) {// 顯示一個(gè)通知對(duì)話框
       37         // 創(chuàng)建一個(gè)對(duì)話框的構(gòu)建者
       38         AlertDialog.Builder builder = new Builder(this);
       39         builder.setIcon(R.drawable.ic_launcher);
       40         builder.setTitle("我是對(duì)話框標(biāo)題");
       41         builder.setMessage("打開黑馬網(wǎng)站");
       42         builder.setPositiveButton("確定", new OnClickListener() {
       43 
       44             public void onClick(DialogInterface dialog, int which) {
       45                 Intent intent = new Intent();
       46                 intent.setAction(Intent.ACTION_VIEW);
       47                 intent.addCategory(Intent.CATEGORY_BROWSABLE);
       48                 intent.setData(Uri.parse("http://edu.csdn.net"));
       49                 startActivity(intent);
       50 
       51             }
       52         });
       53         builder.setNegativeButton("取消", new OnClickListener() {
       54 
       55             public void onClick(DialogInterface dialog, int which) {
       56                 // 用戶點(diǎn)擊取消 會(huì)關(guān)閉掉對(duì)話框
       57             }
       58         });
       59         AlertDialog dialog = builder.create();
       60         dialog.show();
       61     }
       62 
       63     public void click2(View view) {// 顯示單選對(duì)話框
       64         // 創(chuàng)建一個(gè)對(duì)話框的構(gòu)建者
       65         AlertDialog.Builder builder = new Builder(this);
       66         builder.setIcon(R.drawable.ic_launcher);
       67         builder.setTitle("單選對(duì)話框");
       68         final String[] items = { "java", ".net", "php" };
       69         builder.setItems(items, new OnClickListener() {
       70 
       71             public void onClick(DialogInterface dialog, int which) {
       72                 Toast.makeText(getApplicationContext(), "選擇了" + items[which], 0)
       73                         .show();
       74             }
       75         });
       76 
       77         AlertDialog dialog = builder.create();
       78         dialog.show();
       79     }
       80 
       81     public void click3(View view) {// 顯示帶按鈕單選對(duì)話框
       82         // 創(chuàng)建一個(gè)對(duì)話框的構(gòu)建者
       83         AlertDialog.Builder builder = new Builder(this);
       84         builder.setIcon(R.drawable.ic_launcher);
       85         builder.setTitle("單選對(duì)話框");
       86         final String[] items = { "java", ".net", "php" };
       87         builder.setSingleChoiceItems(items, 2, new OnClickListener() {
       88 
       89             public void onClick(DialogInterface dialog, int which) {
       90                 Toast.makeText(getApplicationContext(), "選擇了" + items[which], 0)
       91                         .show();
       92                 dialog.dismiss();
       93             }
       94         });
       95 
       96         AlertDialog dialog = builder.create();
       97         dialog.show();
       98     }
       99 
      100     public void click4(View view) {// 顯示帶按鈕多選對(duì)話框
      101         // 創(chuàng)建一個(gè)對(duì)話框的構(gòu)建者
      102         AlertDialog.Builder builder = new Builder(this);
      103         builder.setIcon(R.drawable.ic_launcher);
      104         builder.setTitle("多選對(duì)話框");
      105         final String[] items = { "java", ".net", "php" };
      106 
      107         builder.setMultiChoiceItems(items,
      108                 new boolean[] { false, true, false },
      109                 new OnMultiChoiceClickListener() {
      110 
      111                     public void onClick(DialogInterface dialog, int which,
      112                             boolean isChecked) {
      113                         if (isChecked) {
      114                             Toast.makeText(getApplicationContext(),
      115                                     "選擇了" + items[which], 0).show();
      116                         } else {
      117                             Toast.makeText(getApplicationContext(),
      118                                     "取消選擇了" + items[which], 0).show();
      119                         }
      120 
      121                     }
      122                 });
      123         builder.setNegativeButton("取消", new OnClickListener() {
      124 
      125             public void onClick(DialogInterface dialog, int which) {
      126 
      127             }
      128         });
      129         AlertDialog dialog = builder.create();
      130         dialog.show();
      131     }
      132 
      133     public void click5(View view) {// 進(jìn)度條對(duì)話框
      134         ProgressDialog pd = new ProgressDialog(this);
      135         // 默認(rèn)是一個(gè)不顯示具體進(jìn)度的對(duì)話框
      136         pd.setMessage("正在下載數(shù)據(jù)....");
      137         pd.show();
      138     }
      139 
      140     public void click6(View view) {// 進(jìn)度條對(duì)話框
      141         final ProgressDialog pd = new ProgressDialog(this);
      142         // 顯示具體進(jìn)度的對(duì)話框
      143         pd.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
      144         pd.setMax(100);
      145         pd.setProgress(20);
      146         pd.show();
      147         new Thread() {
      148             public void run() {
      149                 for (int i = 0; i < 100; i++) {
      150                     pd.setProgress(i);
      151                     try {
      152                         Thread.sleep(100);
      153                     } catch (InterruptedException e) {
      154                         // TODO Auto-generated catch block
      155                         e.printStackTrace();
      156                     }
      157                 }
      158             };
      159         }.start();
      160     }
      161 }

      基礎(chǔ)/08/dialog

       

      posted @ 2013-01-19 20:26  王世楨  閱讀(272)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 国产精成人品日日拍夜夜| 国产成人精品无码播放| 成人白浆一区二区三区在线观看| 亚洲中文字幕aⅴ天堂| 丰满人妻熟妇乱又仑精品| 久久精品国产男包| 国产AV福利第一精品| 香港| 在线天堂中文新版www| 日韩午夜无码精品试看| 亚洲理论在线A中文字幕| 69精品丰满人妻无码视频a片| 亚洲和欧洲一码二码三码| 亚洲中文字幕无码专区| 国产成人综合色就色综合| 色综合天天色综合久久网| 无码精品人妻一区二区三区中| 国产精品多p对白交换绿帽| 国产suv精品一区二区33| 亚洲欧美日本久久网站| 人妻换着玩又刺激又爽| 国产精品久久久久久无毒不卡| 门头沟区| 少妇人妻挤奶水中文视频毛片 | 国产综合精品91老熟女| 成人免费亚洲av在线| 国产麻豆md传媒视频| 久久国内精品自在自线91| 日本一区二区三区在线看| 久在线视频播放免费视频| 精品无码老熟妇magnet| 人妻另类 专区 欧美 制服| 欧美成人精品在线| 国产一区二区三区在线看| 老司机久久99久久精品播放免费| 91福利一区二区三区| 惠安县| 国产精品美腿一区在线看| 亚洲精品国产精品乱码不卡 | 少妇被无套内谢免费看| 女性高爱潮视频|