Android對話方塊Dialog 的一點小問題

來源:互聯網
上載者:User

標籤:android alertdialog dialog

為了在對話方塊中使用editText輸入文字,別的自訂方法都沒用,得這樣:

Dialog dialog = new Dialog(context);

但這樣會有個討厭的title,所以得去掉:

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

在自訂對話方塊時,有時候需要寬度全屏,但部分Activity的主題會有問題,所以需要加上:

Window window = dialog.getWindow();WindowManager.LayoutParams lp = window.getAttributes();lp.width = WindowManager.LayoutParams.MATCH_PARENT;window.setAttributes(lp);

有些繼承AlertDialog的自訂對話方塊則需要寫在onCreate()方法裡.

開啟對話方塊時顯示軟鍵盤:

 dialog.getWindow().setSoftInputMode (WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);


Android對話方塊Dialog 的一點小問題

聯繫我們

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