title: How to reuse layout set in setContentView? Android
body: <p>I am trying to use <code>android:configChanges="keyboardHidden|orientation|screenSize"</code> in my Manifest so that I cannot lose state of my <code>VideoView</code> when configuration changes happen. This means I need to choose the layouts myself on the configuration. The problem I am having is that when I first initialize which view to use in <code>onCreate</code>, here: </p>
  
  <pre><code> @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          if (getResources().getConfiguration().orientation ==
                  Configuration.ORIENTATION_LANDSCAPE) {
              setContentView(R.layout.activity_make_photo_video_land);
  
          } else if (getResources().getConfiguration().orientation ==
                  Configuration.ORIENTATION_PORTRAIT) {
              setContentView(R.layout.activity_make_photo_video);
          }
  }
  </code></pre>
  
  <p>It chooses the right layout. But when I need to adjust the layout on the configuration change like here:</p>
  
  <pre><code>@Override
      public void onConfigurationChanged(Configuration newConfig) {
          super.onConfigurationChanged(newConfig);
  
          if (getResources().getConfiguration().orientation ==
                  Configuration.ORIENTATION_LANDSCAPE) {
              setContentView(R.layout.activity_make_photo_video_land);
          } else if (getResources().getConfiguration().orientation ==
                  Configuration.ORIENTATION_PORTRAIT) {
              setContentView(R.layout.activity_make_photo_video);
          }
  
  
      }
  </code></pre>
  
  <p>It does not use the same instance of the layout, but rather reloads it, which makes my <code>VideoView</code> go black. Then I am unable to press any buttons after that.</p>
  
  <p>Is there a way to reuse the initial layouts? I have tried to set the views like this one <code>setContentView(R.layout.activity_make_photo_video_land);</code> to an <code>Activity activity</code> object, but IDE won't let me, it says <code>Activity is incompatible with void</code>. Because if I could get a reference to that view, then I could reuse it. Or is there a simpler way of doing this that I am not seeing?</p>
  
  <p>Thanks.</p>
  
  <p><img src="https://i.stack.imgur.com/FvTBV.png" alt="enter image description here"></p>