Redraw LinearLayout after change of orientation
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/456211/activity-restart-on-rotation-android">Activity restart on rotation Android</a>  </p>
</blockquote>



<p>I've got a LinearLayout that I want to be <code>android:orientation="vertical"</code> when in portrait mode, and <code>android:orientation="horizontal"</code> when in landscape. The activity performs some complex operations, so allowing the activity to close and restart itself on an orientation change is not an option, so that rules out using the layout-land feature or anything else involving restarting the activity. I am currently programmatically setting the correct <code>android:orientation</code> in activity's <code>onStart</code> and <code>onConfigurationChanged</code>.</p>

<p>Unfortunately, only about 20% of the time does it actually change the layout when you rotate the screen. I haven't been able to pick up on a pattern - it seems to do it sometimes, and other times it doesn't. I've tried calling <code>.invalidate()</code> on the LinearLayout after performing the change, but that didn't seem to work. How can I force the view to redraw with the new orientation, or there some better way to accomplish this?</p>

<p>Basically, here's the code in question that works sometimes, but not others:</p>

<pre><code>@Override
public void onConfigurationChanged(Configuration newConfig) {
    ((LinearLayout)contentView.findViewById(R.id.someLinearLayout))
        .setOrientation(newConfig.orientation==Configuration.ORIENTATION_PORTRAIT ? 
                LinearLayout.VERTICAL
                : LinearLayout.HORIZONTAL);
}
</code></pre>
