Why do I need to call removeView() in order to add a View to my LinearLayout <p>I am getting this error but I am not sure exactly why:</p> <pre><code>java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first. </code></pre> <p>The part where I add the View is the line that the error is pointing to. I am providing my Adapter code in order for you guys to get a better picture of what I am doing and why I am getting this error. Please let me know if anymore info is needed. Thanks in advance.</p> <p><strong>Adapter</strong></p> <pre><code>private class InnerAdapter extends BaseAdapter{ String[] array = new String[] {"12\nAM","1\nAM", "2\nAM", "3\nAM", "4\nAM", "5\nAM", "6\nAM", "7\nAM", "8\nAM", "9\nAM", "10\nAM", "11\nAM", "12\nPM", "1\nPM", "2\nPM", "3\nPM", "4\nPM", "5\nPM", "6\nPM", "7\nPM", "8\nPM", "9\nPM", "10\nPM", "11\nPM"}; TextView[] views = new TextView[24]; public InnerAdapter() { TextView create = new TextView(DayViewActivity.this); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 62, getResources().getDisplayMetrics()), 1.0f); params.topMargin = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()); params.bottomMargin = (int)TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 1, getResources().getDisplayMetrics()); create.setLayoutParams(params); create.setBackgroundColor(Color.BLUE); create.setText("Test"); views[0] = create; for(int i = 1; i &lt; views.length; i++) { views[i] = null; } } @Override public int getCount() { // TODO Auto-generated method stub return array.length; } @Override public Object getItem(int position) { // TODO Auto-generated method stub return null; } @Override public long getItemId(int position) { // TODO Auto-generated method stub return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(parent.getContext()); convertView = inflater.inflate(R.layout.day_view_item, parent, false); } ((TextView)convertView.findViewById(R.id.day_hour_side)).setText(array[position]); LinearLayout layout = (LinearLayout)convertView.findViewById(R.id.day_event_layout); if(views[position] != null) { layout.addView((TextView)views[position], position); } return convertView; } } </code></pre> <p><strong>XML</strong></p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="61dp" android:orientation="horizontal" &gt; &lt;LinearLayout android:layout_width="wrap_content" android:layout_height="61dp" android:orientation="vertical"&gt; &lt;TextView android:id="@+id/day_hour_side" android:layout_width="wrap_content" android:layout_height="60dp" android:text="12AM" android:background="#bebebe" android:layout_weight="0" android:textSize="10dp" android:paddingLeft="5dp" android:paddingRight="5dp"/&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="1dp" android:layout_weight="0" android:background="#000000" android:id="@+id/hour_side_divider"/&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="0dp" android:layout_height="61dp" android:orientation="vertical" android:layout_weight="1"&gt; &lt;LinearLayout android:id="@+id/day_event_layout" android:layout_width="match_parent" android:layout_height="60dp" android:orientation="horizontal" &gt;&lt;/LinearLayout&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="1dp" android:background="#000000" android:id="@+id/event_side_divider" /&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; </code></pre>