title: dynamic generation of layout view inside scrollbar
body: <p>I am facing an issue where I need to generate dynamic views one below another inside a scrollview. Views should be generated after button click.</p>
  
  <p>for the first button click, it is working fine but after second click it is failing with error "java.lang.IllegalStateException: ScrollView can host only one direct child"</p>
  
  <p>can anyone help me to get this fixed.</p>
  
  <p>My main activity layout where scrollview is activity_main.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
          tools:context=".MainActivity" android:layout_width="match_parent" android:layout_height="match_parent"
          android:id="@+id/parentRL"&gt;
      &lt;Spinner android:id="@+id/spinState" android:layout_width="wrap_content" android:layout_height="wrap_content"/&gt;
      &lt;Spinner android:id="@+id/spinCity" android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:layout_below="@id/spinState"/&gt;
      &lt;TextView android:id="@+id/cityCount" android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:layout_toRightOf="@id/spinCity" android:layout_below="@id/spinState" android:layout_marginLeft="5dp" 
          android:textIsSelectable="false"/&gt;
      &lt;Button android:id="@+id/showAddress" android:layout_width="wrap_content" android:layout_height="wrap_content"
          android:layout_toRightOf="@id/spinState" android:onClick="populateAddress" android:text="Search"/&gt;
      &lt;ScrollView android:id="@+id/scView" android:layout_width="match_parent" android:layout_height="wrap_content"
          android:layout_below="@id/spinCity"&gt;
      &lt;/ScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And the view layout that need to be attached with scrollview is address_layout.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TextView android:id="@+id/center" android:layout_width="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_height="wrap_content" android:text="@string/hello_world" android:layout_margin="10dp"
          android:textColor="#FF0000" android:textSize="30dp"
  /&gt;
  </code></pre>
  
  <p>In main activity, inside button click listener:</p>
  
  <pre><code>LayoutInflater inflater = (LayoutInflater)MainActivity.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View myView = inflater.inflate(R.layout.address_layout, null);
  TextView _c_ = (TextView)(myView.findViewById(R.id.center));
  _c_.setVisibility(View.VISIBLE);
  _c_.setText(my_random_number);
  View insertPoint = findViewById(R.id.scView);
  ((ViewGroup) insertPoint).addView(myView, 0, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
  </code></pre>