Missing initialization of mSubtitleVisible

At the end of page 264, when I tried to run CriminalIntent it crashed.

logcat says I’m getting a NullPointerException at line 69 of CrimeListFragment.java


if (mSubtitleVisible) {
    } else {

So mSubtitleVisible is null.

To resolve this, I added a conditional initialization in the onCreateView method after the mCrimeRecyclerView is set:

        if (mSubtitleVisible == null){
        mSubtitleVisible = false;

Not sure if this is the approach we’d need to take or how else we should be initializing this.

Hi mattjn,

Please paste the whole method onCreateOptionsMenu() method in the CrimeListFragment.java.
I guess the issue may be due to the the null value of subtitleItem, not mSubtitleVisible. mSubtitleVisible is a boolean value and it cannot be a null value.