0

我已经实现了在菜单DatePickerDialogFragment上的 clcik 之后显示的内容。ActionBar物品。我正在关注 android 开发者示例http://developer.android.com/guide/topics/ui/controls/pickers.html现在我需要在另一个中显示日期fragment(我NavigationDrawer在 MainActivity 中使用)。我尝试将数据放入bundle方法中onDateSet,但是当我尝试在片段中获取数据时,它以 NPE 结尾。请问有人可以帮我解决这个问题吗?谢谢我感谢每一个帮助。

4

1 回答 1

0

lets say you keep a static Date variable in the parent activity, when date is picked save the date picked in the static variable with the getActivity() method, and then switch fragments.

然后在第二个片段的 onViewCreated 方法中,只需使用父活动中的日期值初始化 datepicker。

于 2013-10-22T07:20:29.933 回答