La vista infantil se agrega a otra vista cada vez que muestro un diálogo

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:

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

_http://i075.radikal.ru/1101/00/f1b132b07e25.jpg

Pero la vista normal debe verse así:

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

¿Por qué sucede?

dialogtable.xml

  <?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="fill_parent">
    <TextView
        android:id="@+id/label"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Type here:"/>
    <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"/>
    <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" />
    <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" />
</RelativeLayout>

El código de MainActivity

@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();
    }
}

preguntado el 09 de enero de 11 a las 09:01

that's impossible to explain without seeing your code related to your dialog. -

I have added my code, please help -

i think it is bcoz you are not dismissing dialog.i think you should copy your project on:gist.github.com . so i can review more. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.