title: removeView (view) not working in subclass of ViewGroup
body: <p>I have a <code>MyLinearLayout</code> subclass extends <code>ViewGroup</code> which make <code>View</code>s inside it auto-wrap.</p>
  
  <pre><code>public class MyLinearLayout extends ViewGroup {
      private final int cellHeight = 70;
  
  
      public MyLinearLayout (Context context, AttributeSet attrs) {
          super (context, attrs);
      }
  
  
      @Override
      protected void onLayout (boolean changed, int l, int t, int r, int b) {
          int left = 40;
          int top = 20;
          int count = getChildCount ();
          int remainingWidth = 0;
  
          for (int j = 0; j &lt; count; j++) {
              View childView = getChildAt (j);
  
              int w = childView.getMeasuredWidth ();
              int h = childView.getMeasuredHeight ();
  
              if (left != 40 &amp;&amp; remainingWidth &lt; w)
              {
                  left = 40;
                  top += (cellHeight + 20);
              }
              childView.layout (left, top, left + w, top + h);
              remainingWidth = r - l - left - w - 80;
              left += (w + 40);
          }
      }
  
  
      @Override
      protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec) {
          int cellWidthSpec = MeasureSpec.makeMeasureSpec (0,
                  MeasureSpec.UNSPECIFIED);
          int cellHeightSpec = MeasureSpec.makeMeasureSpec (cellHeight,
                  MeasureSpec.EXACTLY);
          int count = getChildCount ();
  
          for (int i = 0; i &lt; count; i++) {
              View childView = getChildAt (i);
              childView.measure (cellWidthSpec, cellHeightSpec);
          }
  
          setMeasuredDimension (resolveSize (0, widthMeasureSpec),
                  resolveSize (cellHeight * count, heightMeasureSpec));
      }
  
  
      public void removeChildViews (ViewGroup rootView) { // not work
          View child;
          if (rootView == null) {
              rootView = this;
          } 
          int count = rootView.getChildCount ();
          Log.i ("---&gt;", count + " start");
          for(int i = 0; i &lt; count; i++) { 
              child = rootView.getChildAt(i);
              Log.i ("---&gt;", rootView.getClass ().toString () + " ROOT");
              Log.i ("---&gt;", child.getClass ().toString () + " CHILD");
              if(child instanceof ViewGroup) {
                  removeChildViews ((ViewGroup) child);
              } else if (child != null) {
                  rootView.removeView (child);
              }
          }
          Log.i ("---&gt;", rootView.getChildCount () + " end");
      }
  
  }
  </code></pre>
  
  <p>and I declare it in my layout file:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/input_layout"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      ...
  
      &lt;LinearLayout
          android:layout_width="match_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:orientation="horizontal" &gt;
          ...
  
          &lt;com.test.MyLinearLayout
              android:id="@+id/llayout_autobreak"
              android:layout_width="match_parent"
              android:layout_height="match_parent" &gt;
          &lt;/com.test.MyLinearLayout&gt;
      &lt;/LinearLayout&gt;
      ...
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>and use it in my <code>Activity</code>:</p>
  
  <pre><code>    @Override
      protected void onCreate (Bundle savedInstanceState) {
          super.onCreate (savedInstanceState);
          setContentView (R.layout.layout_input);
  
          ...
  
          ll_ab = (MyLinearLayout) findViewById (R.id.llayout_autobreak);
  
          spinner.setOnItemSelectedListener (new OnItemSelectedListener () {
  
                      @Override
                      public void onItemSelected (AdapterView &lt;?&gt; parent,
                              View view, int position, long id) {
  
                          ll_ab.removeChildViews(null); // not work
                          ...
                          ...
                      }
  
                      @Override
                      public void onNothingSelected (AdapterView &lt;?&gt; parent) {
  
                      }
                  });
  
                  ...
      }
  </code></pre>
  
  <p>The <code>ll_ab</code> layout in my <code>Activity</code> may contain many different <code>View</code>s, such as <code>TextView</code>, <code>EditView</code>, <code>Spinner</code>, etc..., I could add them to <code>ll_ab</code> layout dynamically, and it works well. However, but when I try to replace them with a set of new <code>View</code>s, the <code>removeChildViews (ViewGroup)</code> in my <code>MyLinearLayout</code> seems only remove <code>TextView</code> but not others. I also try to use <code>removeAllViews()</code>, but it does not work, too. So, how to remove all Views inside <code>ll_ab</code>? Thank you so much for the help.</p>