如何实现确认(是/否)DialogPreference? [英] How to implement a confirmation (yes/no) DialogPreference?
本文介绍了如何实现确认(是/否)DialogPreference?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何实现显示简单的是/否确认对话框的首选项?
How can I implement a Preference that displays a simple yes/no confirmation dialog?
示例见Browser->Setting->Clear Cache
.
推荐答案
那是一个简单的警报对话框,Federico 为您提供了一个网站,您可以在其中查找内容.
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();
这篇关于如何实现确认(是/否)DialogPreference?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文