在我的应用程序中,我使用了一个警告对话框构建器来单击按钮。因此,当我按下一个按钮时,会弹出一些弹出窗口,其中包含选项 - 激活和取消激活。因此,当用户按下激活或取消激活时,我可以确定,确认widnows打开时有问题吗?选择是或否?
答案 0 :(得分:2)
是。阅读此http://developer.android.com/guide/topics/ui/dialogs.html#AlertDialog。用户按下激活或取消激活按钮后弹出此对话框。
答案 1 :(得分:2)
我在另一个对话框中创建了对话框。
请参阅此代码:
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
}
});
请参考您的情况,它会对您有帮助。
享受。 :))
答案 2 :(得分:0)
大声笑..窗户技术。是的,这是可能的,只需弹出另一个对话框,在那之后。