Share the post "NoSaveStateFrameLayout In findViewById Within Fragment"
If you get a NullPointerException because the view returned by findViewById() is of type NoSaveStateFrameLayout, I am guessing you called the findViewById() method from within the overriden onViewCreated() method in the Fragment class that you extended by using the View parameter.
The solution to getting the correct View is to use the Fragment‘s getActivity() method instead.
Do this and you should be fine.
|
1 2 3 4 |
@Override public void onViewCreated(final View view, Bundle savedInstanceState) { FrameLayout fl = (FrameLayout) getActivity().findViewById(...); } |