title: Attempt to write to field 'int android.app.Fragment.mNextAnim' on a null object reference
body: <p>im trying to use fragments- changeing fragments with if and else.
  i came cross with this error when im trying to run the program:</p>
  
  <p><strong>"Attempt to write to field 'int android.app.Fragment.mNextAnim' on a null object reference"</strong></p>
  
  <p>i search of answers and i saw that mybe the sulotion is to import the Fragmet.support.v4.app.Fragment</p>
  
  <p>so tried that and i cant change to this import
  what should i do or it other sulotion?</p>
  
  <pre><code>import android.app.Fragment;
  import android.app.FragmentManager;
  import android.app.FragmentTransaction;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  
  public class MainActivity extends AppCompatActivity implements  View.OnClickListener {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      if(isInSingleFrragment()){
          FragmentManager fm = getFragmentManager();
          Fragment fragmentB = fm.findFragmentById(R.id.FragmetB);
          FragmentTransaction ft=fm.beginTransaction();
          ft.hide(fragmentB);
          ft.commit();
  
          Button switchbutton = (Button)findViewById(R.id.switchbutton);
          switchbutton.setOnClickListener(this);
      }
  }
  
  private boolean isInSingleFrragment() {
  
      View layout = findViewById(R.id.singleLayout);
  
      if (layout != null) {
          return true;
      } else {
          return false;
      }
  }
  @Override
  public void onClick(View v) {
      switch (v.getId()){
          case R.id.switchbutton:
              switchFragments();
              break;
      }
  
  }
  
  private void switchFragments() {
  
      FragmentManager fm = getFragmentManager();
      Fragment fragmentA = fm.findFragmentById(R.id.FragmetA);
      Fragment fragmentB = fm.findFragmentById(R.id.FragmetB);
  
      FragmentTransaction ft = fm.beginTransaction();
  
      if(fragmentA.isVisible()){
          ft.hide(fragmentA);
          ft.show(fragmentB);
      }else {
          ft.hide(fragmentB);
          ft.show(fragmentA);
      }
      ft.commit();
  }
  }
  </code></pre>