是或在Android的preferences没有确认 [英] Yes or No confirmation in Android Preferences
问题描述
我需要实现一个设置重置选项。当单击该设置,一个简单的对话框应该打开要求确认。
I need to implement a "Reset" option in Settings. When the setting is clicked, a simple dialog should open asking to confirm.
我已经采取了看看对话preference
,但我不能似乎能够找到一个很好的解决方案,或教程的任何地方。是否有人可以帮助我吗?我是一个初学者,想法甚至code将是非常有益的,谢谢。
I've taken a look at DialogPreference
but I can't seem to be able to find a good solution, or tutorials anywhere. Can someone please help me out? I'm a beginner, ideas or even code would be very helpful, thank you.
推荐答案
检查此链接。使用 AlertDialog.Builder
,它很容易做到的。
Check this link . use AlertDialog.Builder
, Its very easy to do
http://developer.android.com/guide/topics/ui/ dialogs.html
其他使用对话preference
..
这添加到preference XML
Add this to preference xml
<com.examples.app.CustomDialogPreference
android:title="Title"
android:dialogMessage="Message"
android:positiveButtonText="Yes"
android:negativeButtonText="No"/>
在您的code,创建自定义对话框。这很奇怪,但你必须
In your code, create a custom Dialog. This is weird, but you have to
public class CustomDialogPreference extends DialogPreference{
public CustomDialogPreference(Context oContext, AttributeSet attrs){
super(oContext, attrs);
}
}
这篇关于是或在Android的preferences没有确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!