如何实现一个确认(是/否)对话框preference? [英] How to implement a confirmation (yes/no) DialogPreference?
本文介绍了如何实现一个确认(是/否)对话框preference?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何实现一个preference显示简单的是/否确认对话框?
How can I implement a Preference that displays a simple yes/no confirmation dialog?
有关示例,请参阅浏览器 - >设置 - >清除缓存
推荐答案
这是一个简单的警告对话框< /一>,费德里科给你一个网站,你可以看看的事情了。
That is a simple alert dialog, Federico gave you a site where you can look things up.
下面是如何构建一个警告对话框一个简单的例子。
Here is a short example of how an alert dialog can be built.
new AlertDialog.Builder(this)
.setTitle("Title")
.setMessage("Do you really want to whatever?")
.setIcon(android.R.drawable.ic_dialog_alert)
.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
Toast.makeText(MainActivity.this, "Yaay", Toast.LENGTH_SHORT).show();
}})
.setNegativeButton(android.R.string.no, null).show();
这篇关于如何实现一个确认(是/否)对话框preference?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文