如何从preference屏幕中打开AlertDialog? [英] How to open AlertDialog from preference screen?
本文介绍了如何从preference屏幕中打开AlertDialog?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发的Android应用程序 我想告诉AlertDialog如果用户检查从preference屏幕的复选框preference。 所以我怎么能做到这一点..?
I am developing Application in android I want to show AlertDialog if user check the checkboxpreference from preference screen. so how i can do that..?
推荐答案
覆盖 onShared preferenceChanged
在 preferenceActivity
类:
public class MyPreferences extends PreferenceActivity implements OnSharedPreferenceChangeListener {
...
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (key.equals("MyCheckboxPreferenceKey")) {
//Show your AlertDialog here!
}
}
这篇关于如何从preference屏幕中打开AlertDialog?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文