gpt4 book ai didi

android - 警报对话框生成器确认按钮

转载 作者:搜寻专家 更新时间:2023-11-01 08:11:30 24 4
gpt4 key购买 nike

在我的应用程序中,我使用了一个警报对话框构建器来点击按钮。因此,当我按下一个按钮时,会打开带有选项的小弹出窗口 - 激活和停用。那么我可以做到这一点吗?以及选择是或否??

最佳答案

我在另一个对话框中创建了对话框。

查看这段代码:

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
}
});

只要引用一下你的情况,它会对你有帮助。

关于android - 警报对话框生成器确认按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9125920/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com