我可以自定義AlertDialog 而不使用自定義對話框?正如我想在對話框上的是或否按鈕後顯示我的取消按鈕。在Android中自定義AlertDialog
-2
A
回答
0
是的,你可以。 在xml中進行自定義佈局。然後將您的自定義xml設置爲您的警報對話框。
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
final View dialogView = inflater.inflate(R.layout.custom_dialog, null);
dialogBuilder.setView(dialogView);
Button yes = (Button) dialogView.findViewById(R.id.yes);
yes.onClickListenere(......./do what you want);
0
這是沒有辦法改變按鈕的順序。但是你可以這樣做並相應地實現所需的按鈕點擊事件。
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
alertDialogBuilder.setMessage("");
alertDialogBuilder.setPositiveButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
});
alertDialogBuilder.setNegativeButton("Yes",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
});
alertDialogBuilder.setNeutralButton("No",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
}
});
AlertDialog alertDialog = alertDialogBuilder.create();
alertDialog.show();
相關問題
- 1. 在自定義AlertDialog中插入SeekBar(Android)
- 2. 在AlertDialog中自定義ListView
- 3. 自定義AlertDialog
- 4. setContentView,微調框自定義alertdialog在android
- 5. IllegalStateException使用自定義adatper和AlertDialog Android
- 6. 在自定義ListAdapter類中顯示AlertDialog
- 7. 在Android中顯示自定義AlertDialog,同時捕獲異常
- 8. 自定義AlertDialog與它
- 9. 與ListView自定義AlertDialog
- 10. 菜單中的自定義AlertDialog?
- 11. Android:在EditText上的自定義AlertDialog上顯示軟鍵盤Focus
- 12. 如何自定義Android AlertDialog中的列表項目
- 13. AlertDialog在android中
- 14. 如何在Android中的AlertDialog中包含自定義標題視圖?
- 15. 將圖像添加到自定義AlertDialog
- 16. 動態設置自定義AlertDialog內容
- 17. 自定義AlertDialog沒有顯示
- 18. 我不能解僱自定義alertdialog框
- 19. 安卓:更改自定義AlertDialog背景
- 20. 關閉clicklistener上的自定義alertdialog
- 21. 自定義AlertDialog無法初始化onCreate()
- 22. 自定義AlertDialog與切斷角落
- 23. 被忽略的自定義AlertDialog大小
- 24. 自定義列表視圖的AlertDialog
- 25. 自定義佈局AlertDialog不起作用?
- 26. 自定義AlertDialog添加了View.onClickListener
- 27. 不能在自定義AlertDialog內得到定製AlertDialog一個ImageView的,更新的
- 28. 在android中自定義seekbar
- 29. 具有自定義視圖的Android AlertDialog:獲取輸入數據
- 30. 顯示自定義對話框一個Android AlertDialog,點擊
告訴我們你的努力 – yuyoyuppe