如何在Android中显示警告对话框?

编程入门 行业动态 更新时间:2024-10-23 23:33:36
本文介绍了如何在Android中显示警告对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我要显示对话框/弹出窗口的消息,用户,显示您确定要删除该条目?与删除一个按钮。在点击按钮删除,应该删除该条目,否则什么都没有。

I want to display dialog/popup window for message to user that shows "Are you sure you want to delete this entry?" with One button of 'Delete' . On click of button Delete, it should delete that entry otherwise nothing.

我已经写了这些按钮的点击监听,但我不知道如何调用对话框或弹出式和它的功能。

I have written a click listener of those buttons but I dont know how to invoke dialog or popup and its functionality.

推荐答案

您可以使用警报生成器这样的:

You could use the alert builder for this:

new AlertDialog.Builder(context) .setTitle("Delete entry") .setMessage("Are you sure you want to delete this entry?") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // continue with delete } }) .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // do nothing } }) .setIcon(android.R.drawable.ic_dialog_alert) .show();

更多推荐

如何在Android中显示警告对话框?

本文发布于:2023-11-27 21:03:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639595.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:对话框   如何在   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!