在某些非常罕见的情况中,此行发生了崩溃:
mCurrentDialogFragment.get()setArguments(束);
protected void showDateTimePickerDialog() {
mCurrentDialogFragment = new WeakReference<AppCompatDialogFragment>(new DateTimePickerDialogFragment());
((DateTimePickerDialogFragment) mCurrentDialogFragment.get()).setOnDateTimeSelectedListener(
new DateTimePickerDialogFragment.OnDateTimeSelectedListener() {
@Override
public void onCancelled() {
}
@Override
public void onDateTimeSet(int year, int monthOfYear, int dayOfMonth,
int hourOfDay, int minute) {
...
});
DateTime dt = new DateTime(mCalendarTimeLineAdapter.convertPositionToMs(
mViewPager.getCurrentItem()));
if (mCurrentDialogFragment != null && mCurrentDialogFragment.get() != null) {
Pair<Boolean, SublimeOptions> optionsPair =
TimeUtils.getDateTimePickerOptionsForDiary(mScheduleRange,
new DateTime(dt), mCalendarTimeLineAdapter.getCalendarTodayPosition());
Bundle bundle = new Bundle();
bundle.putParcelable(DateTimePickerDialogFragment.BUNDLE_KEY_DATETIME_OPTIONS, optionsPair.second);
// **** CRASH HERE
mCurrentDialogFragment.get().setArguments(bundle);
mCurrentDialogFragment.get().setStyle(android.support.v4.app.DialogFragment.STYLE_NO_TITLE, 0);
mCurrentDialogFragment.get().show(getSupportFragmentManager(), TAG);
}
}
怎么可能?我无法理解引用如何为null ...
你们有一些解释吗?
非常感谢
答案 0 :(得分:-2)
尝试初始化您的Dialoig mCurrentDialogFragment = null
,然后分配它。