When rotating the screen, the instances of the controls are lost?

2

Curiously enough I have not had problems with rotating the screen and controls, until now, I have my controls, until the Fragment arrived I have that happy problem when rotating the device loses the instance of the controls:

  

java.lang.NullPointerException: Attempt to invoke virtual method   'android.text.Editable android.widget.EditText.getText ()' on a null   object reference

Method that controls the data:

    viewPager.setOffscreenPageLimit(2);
    MF_F_Datos mff_data = (MF_F_Datos) adapter.getItem(0);
    MF_F_Galeria mff_galeria = (MF_F_Galeria) adapter.getItem(1);

    mff_data.ActMuestraDatos(_id_mf_l, mod);

As long as you do not rotate the screen the app works fine.

    
asked by Mark Dev 16.12.2016 в 18:42
source

1 answer

1

You can use in your Activity:

 <activity
        android:name=".myActivity"         
        android:configChanges="keyboardHidden|orientation|screenSize"/>   

with this it would not destroy the Activity or the Fragment that contains it but this type of error that you comment:

  

When rotating the screen are the instances of the controls lost?

It is possible that the references are lost, this may be because you have a different Layout defined for another orientation.

    
answered by 16.12.2016 / 18:51
source