Android的 - 警告对话框建设者确认按钮 [英] android - alert dialog builder confirmation button
本文介绍了Android的 - 警告对话框建设者确认按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的应用我已经使用按钮点击一个警告对话框建设者。所以,当我preSS按钮,有点弹出打开的选项 - 激活和停用。这样可以让我在用户preSS启动或关闭,确认WIDNOWS打开的问题你确定吗?和一个选择是或否?
In my app I have used an alert dialog builder for button click. So when I press a button, little pop up is opened with options - Activate and Deactivate. So can i make that when a user press Activate or Deactivate, Confirmation widnows open with question are you sure ? and a choice yes or no ??
推荐答案
我创建对话框另一个对话框中。
I have created dialog inside another dialog.
请参阅此code:
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
}
});
只是指,对于您的情况,它会帮助你。
Just refer that for your condition and it will help you.
享受。 :))
这篇关于Android的 - 警告对话框建设者确认按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文