自訂AlertDialog控制項的使用(AndroidStudio)

來源:互聯網
上載者:User

標籤:

AlertDialog 第一種:可隨意自訂控制項

                    第一步:自訂彈出的頁面 ,建立一個XML頁面 如  不需要Activity

                        

  第二步:在首頁面設定一個按鈕彈出頁面  (下面是主要代碼  調用自動以XML檔案顯示在AlertDialog中)
final AlertDialog dialog = new AlertDialog.Builder(container.getContext()).create();//執行個體化一個AlertDialog
dialog.show();    //把AlertDialog初始化
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);//設定將IME顯示出來
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);  //指定IME顯示在該視窗  設定IME可見度
final Window window = dialog.getWindow(); //執行個體化一個視窗
window.setContentView(R.layout.activity_alert_error_document);//調用自訂的XML放到AlertDialog中展示
TextView txtDocumentNumber = (TextView) window.findViewById(R.id.txtDocumentNumber);//擷取自訂XML的控制項

自訂AlertDialog控制項的使用(AndroidStudio)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.