A
A
androd2016-11-07 19:39:37
Android
androd, 2016-11-07 19:39:37

How to avoid NullPointerException on orientation change in application with FragmentTabHost?

I have an application that I developed for a long time and initially turned off the orientation change - left only portrait.
Over time, the application has grown and now, when I want to make it work in both portrait and landscape orientations, a java.lang.NullPointerException
error pops up. located on this layout.
I must say that this is one of the 4 layouts that are in FragmentTabHost.
And when defining the button, there is no error.

helpBtn = (Button) rootView.findViewById(R.id.helpBtn);

it comes when any of its properties are changed, for example:
helpBtn.setVisibility(View.GONE);
It must be said that this is one of 4 layouts and each of them is in FragmentTabHost
android:configChanges="orientation|keyboardHidden|screenSize"

android:configChanges tried different ones, always when switching FragmentTabHost to this layout in landscape orientation, a java.lang.NullPointerException occurs on changing the properties of this button
helpBtn.setVisibility(View.GONE);
. Moreover, in this layout there are other buttons and controls on them, no error occurs, but on this and another two - arises.
Please help me figure it out.
I'm ready to receive the answer privately, and then post it here.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question