安卓學習中的知識AlertDialog

來源:互聯網
上載者:User

標籤:

AlertDialog可以再當前介面彈出一個對話方塊,這個對話方塊是置頂於所有介面元素之上,能夠屏蔽其它控制項的互動能力,MainActivity裡插入簡要代碼。其功能在於提示使用者你是否要繼續接下的操作,還有這個操作的一些提醒。

 1 AlertDialog.Builder dialog =new AlertDialog.Builder(UiLayoutActivity.this);//建立環境 2                     dialog.setTitle("this is dialog");//建立的對話方塊標題 3                     dialog.setMessage("something important");//輸入對話方塊的提示內容 4                     dialog.setCancelable(false); 5                     dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {//選擇項,直接由編譯器匯入即可 6                          7                         @Override 8                         public void onClick(DialogInterface dialog, int which) { 9                             // TODO Auto-generated method stub10                             11                         }12                     });13                     dialog.setNegativeButton("cancle", new DialogInterface.OnClickListener() {//選擇項14                         15                         @Override16                         public void onClick(DialogInterface dialog, int which) {17                             // TODO Auto-generated method stub18                             19                         }20                     });21                     dialog.show();22                     break;23                     default:24                         break;25                 }

 

安卓學習中的知識AlertDialog

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.