title: Layout not refreshing after orientation change
body: <p>I have the following Activity definition:</p>
  
  <pre><code>&lt;LinearLayout
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:id="@+id/inspectionMainLayout"
      xmlns:android="http://schemas.android.com/apk/res/android"&gt;
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="50dp"
          android:singleLine="false"
          android:id="@+id/breadCrumb"
          android:visibility="gone"&gt;
      &lt;/LinearLayout&gt;
  
      &lt;ExpandableListView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:id="@+id/expandableListView" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Now in my code I do add buttons dynamically in breadCrumb LinearLayout:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_inspection);
      LinearLayout mainLayout = (LinearLayout) findViewById(R.id.inspectionMainLayout);
  
      if (mainLayout != null) {
          ExpandableListView list = (ExpandableListView) findViewById(R.id.expandableListView);
  
          list.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
              @Override
              public boolean onChildClick(ExpandableListView expandableListView, View view, int i, int i2, long l) {
                  LinearLayout breadCrumb = (LinearLayout) findViewById(R.id.breadCrumb);
  
                  Button filterButton = new Button(InspectionActivity.this);
                  filterButton.setOnClickListener(new View.OnClickListener() {
                      @Override
                      public void onClick(View view) {
                          onFilterButtonClick((Button) view);
                      }
                  });
  
                  filterButton.setText(item.getFormattedFilter());
  
                  breadCrumb.addView(filterButton);
              }
          }
      }       
      ...
  }
  </code></pre>
  
  <p>This code works well, until I do not change the device orientation and my Activity is recreated. Although all the code is executing correctly, screen seems not being updated. Once I restore the previous orientation, all the items suddenly appear. Any idea why and how to fix it?</p>
  
  <p>Thanks</p>
  
  <p>EDIT:</p>
  
  <p>I do think that I'm running into the same problem as describe in this post:
  <a href="https://stackoverflow.com/questions/10151975/android-findviewbyid-gives-me-wrong-pointer">Android: findViewById gives me wrong pointer?</a></p>
  
  <p>Any idea on how to solve this?</p>
  
  <p>As requested my onRestoreInstanceState:</p>
  
  <pre><code>@Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
      super.onRestoreInstanceState(savedInstanceState);
  
      baseCategories = savedInstanceState.getParcelable(BASE_CATEGORIES_STATE);
      currentFilter = savedInstanceState.getParcelable(FILTERS_STATE);
  }
  </code></pre>
  
  <p>and on onSaveInstanceState:</p>
  
  <pre><code>@Override
  protected void onSaveInstanceState(Bundle outState) {
      super.onSaveInstanceState(outState);
  
      outState.putParcelable(BASE_CATEGORIES_STATE, baseCategories);
      outState.putParcelable(FILTERS_STATE, currentFilter);
  }
  </code></pre>
  
  <p>now both of my classes do implement Parcelable interface.
  They are persisted and restored correctly.</p>
  
  <p>Still for some resaon the call to the findViewById get's me pointed to the wrong object (not the one that is recreated).</p>