[英]android - alert dialog builder confirmation button
在我的應用程序中,我使用了一個警報對話框構建器來單擊按鈕。 因此,當我按下按鈕時,會打開帶有選項的小彈出窗口 - 激活和停用。 那么,當用戶按下激活或停用時,我可以做到這一點,確認窗口會打開問題,你確定嗎? 和選擇是或否??
是的。 閱讀此http://developer.android.com/guide/topics/ui/dialogs.html#AlertDialog 。 用戶按下激活或停用按鈕后彈出此對話框。
我在另一個對話框中創建了對話框。
請參閱此代碼:
twsbiSelectionMenuDialog = new Dialog(this,R.style.CustomDialogTheme);
twsbiSelectionMenuDialog.setContentView(R.layout.twsbi_selection_menu_dialog);
twsbiSelectionMenuDialog.setCancelable(true);
twsbiSelectionMenuDialog.setCanceledOnTouchOutside(true);
// To Open new Canvas ===================================
Button newLayoutButton = (Button) twsbiSelectionMenuDialog.findViewById(R.id.newLayoutButton);
newLayoutButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
twsbiSelectionMenuDialog.dismiss();
// AlertDialog for confirmation
AlertDialog.Builder clearConfirmDialog = new AlertDialog.Builder(TWSBIDrawMainActivity.this);
clearConfirmDialog.setMessage("Do you want to clear this and open new canvas ?").setCancelable(false)
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'Yes' Button
myView = new MyView(TWSBIDrawMainActivity.this);
takePhotoFromCamera = false;
takePhotoFromGallery = false;
canvasColor = 0xFFFFFFFF;
drawingLayout.removeView(myView);
drawingLayout.addView(myView);
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
// Action for 'NO' Button
dialog.cancel();
}
});
AlertDialog alert = clearConfirmDialog.create();
alert.setTitle("Draw");
alert.setIcon(R.drawable.app_icon);
alert.show();
}
});
// For canvas Color Selection ===================================
Button canvasColorButton = (Button) twsbiSelectionMenuDialog.findViewById(R.id.canvasColorButton);
canvasColorButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
twsbiSelectionMenuDialog.dismiss();
pickColour(); // to pick colour
}
});
只需參考您的情況,它就會對您有所幫助。
窗戶技術。 是的,這是可能的,只需在該對話框之后彈出另一個對話框。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.