Rotating Android device while viewing dialog preference with TimePicker or NumberPicker causes app crash

不羁岁月 提交于 2019-12-04 17:00:33

I found the solution to this problem here: https://code.google.com/p/android/issues/detail?id=22754#c5, which says the following:

in the onCreate Method, put the following after you findviewbyId for the time picker:

tp.setSaveFromParentEnabled(false);
tp.setSaveEnabled(true);

This got rid of the error. However, the dialog doesn't stay open. But this seems to be the default functionality for all non-custom preferences, so I'm happy with it.

Here are the docs for the two methods used above:

And here are gists that I've posted of my final working custom Preferences:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!