本文介绍了如何在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中显示警告对话框?
发布评论