Child view adds itself to another view every time when I show dialog
<p>A child view had joined the main view. I don't want it to be so. Look at the screenshot. But I want that the dialog has appeared and it disappeared, and the view of the dialog didn't join itself to main view. After I called dialog, the view of the it joined every time and it looked like this: </p>

<p>_http://s014.radikal.ru/i329/1101/cc/4ce75c9e8ae2.jpg</p>

<p>_http://i075.radikal.ru/1101/00/f1b132b07e25.jpg</p>

<p>But the normal view must look like this:</p>

<p>_http://i016.radikal.ru/1101/64/0b2a4718cd0e.jpg</p>

<p>Why it happens?</p>

<p>dialogtable.xml</p>

<pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"&gt;
    &lt;TextView
        android:id="@+id/label"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Type here:"/&gt;
    &lt;EditText
        android:id="@+id/entry"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:drawable/editbox_background"
        android:layout_below="@id/label"/&gt;
    &lt;Button
        android:id="@+id/ok"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/entry"
        android:layout_alignParentRight="true"
        android:layout_marginLeft="10dip"
        android:text="OK" /&gt;
    &lt;Button
        android:id="@+id/cancel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/ok"
        android:layout_alignTop="@id/ok"
        android:text="Cancel" /&gt;
&lt;/RelativeLayout&gt;
</code></pre>

<p>The code from MainActivity</p>

<pre><code>@Override
protected Dialog onCreateDialog(int id) {
    LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);

    View layout = inflater.inflate(R.layout.dialogtable, (ViewGroup)findViewById(R.id.LinearLayout01));

    AlertDialog.Builder alert = null;
    alert = new AlertDialog.Builder(this);
    alert.setView(layout);
    alert.setTitle("Create table");
    alert.setCancelable(false);
    alert.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {

        @Override
            public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    alert.setPositiveButton("OK",new DialogInterface.OnClickListener() {

        @Override
            public void onClick(DialogInterface dialog, int which) {

            Editable rows = fieldForRows.getText();
            Editable columns = fieldForColumns.getText();
            Editable border = fieldForWidthOfBroder.getText();


            TableAction tableAction = new TableAction(MainActivity.this.visualPane);
            tableAction.insertTable(rows, columns, border);
        }
    });
    Dialog dialog = null;
    dialog = new Dialog(this);
    switch (id) {
    case IDD_CUSTOM_INSERT_TABLE:
        dialog.setTitle("Insert table");
        dialog.setContentView(R.layout.dialogtable);
        return dialog;
    case IDD_CUSTOM_INSERT_IMAGE:
        dialog.setTitle("Insert image");
        return dialog;
    default:
        return alert.create();
    }
}
</code></pre>
