> 
> ERROR/AndroidRuntime(10985): Caused by: java.lang.IllegalStateException:The specified child already has a parent.You must call removeView() on the child's parent first.
> 
> 
> 

This is my XML `tabs_dettaglio.xml` I use for visual tabs:

Codice (XML): [Seleziona]

```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal"
    android:id="@+id/relativeimg" 
    >
    <RelativeLayout 
        android:id="@+id/relativeimg1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        >
        <ImageView 
            android:layout_width="wrap_content" 
            android:id="@+id/imageView3" 
            android:layout_height="wrap_content"  
            android:layout_marginLeft="10dip">
        </ImageView>
    </RelativeLayout>
    <RelativeLayout 
        android:id="@+id/relativeimg2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        >
        <ImageView 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:id="@+id/imageView2"  
            android:layout_marginLeft="220dip">
        </ImageView>
    </RelativeLayout>
    <RelativeLayout 
        android:id="@+id/relativeimg3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        >
        <ImageView 
            android:layout_height="wrap_content" 
            android:layout_width="wrap_content" 
            android:id="@+id/imageView1"  
            android:layout_marginLeft="97dip">
        </ImageView>
    </RelativeLayout>
</RelativeLayout>

```

**this is java code :**

```
private void setTabs() {
    tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("1").setContent(new Intent(this,d.class)).setIndicator(addImg(1)));
    tabHost.addTab(tabHost.newTabSpec("2").setContent(new Intent(this,d.class)).setIndicator(addImg(2)));
    tabHost.addTab(tabHost.newTabSpec("3").setContent(new Intent(this,d.class)).setIndicator(addImg(3)));
}

private View addImg(int i) {
    int cc;
    int cc2;
    if(i==1) {
        cc = R.id.imageView3;
        cc2 = R.drawable.menu_oggi;
    } else if(i==2){
        cc = R.id.imageView2;
        cc2 = R.drawable.menu_ieri;
    } else {
        cc = R.id.imageView1;
        cc2 = R.drawable.menu_domani;
    }
    View tabIndicator = LayoutInflater.from(getBaseContext()).inflate(R.layout.tabs_dettaglio,null);                
    ImageView icon = (ImageView) tabIndicator.findViewById(cc);
    icon.setBackgroundResource(cc2);
    return icon;
}               

```