我在 Xamarin(C#) 上写安卓应用
当我点击 Activity 上的后退按钮时,我需要显示带有"is"和“否”的提醒变体。
我怎样才能意识到这一点?
我知道如何表现出警惕。当我按下后退按钮时我如何做到这一点
最佳答案
试试这个,添加到你的 Activity 中
@Override
public void onBackPressed() {
AlertDialog.Builder builder =
new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setTitle(getResources().getString(R.string.app_name));
builder.setMessage("" + Message);
builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
//write your code
}
});
builder.setNegativeButton("No", null);
builder.setCancelable(false);
builder.show();
}
关于c# - 按后退按钮时显示警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34433012/