title: The specified child already has a parent. You must call removeView() on the child's parent first
body: <p>I have a class to create the dialog and coding to get the values from it. it works fine for one. and when i try to call dialog for the second time it passes following error message.</p>
  
  <blockquote>
    <p>: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.</p>
  </blockquote>
  
  <p>Can you please tell me how to remove the removeView()?</p>
  
  <p>here is the code for the class;</p>
  
  <pre><code>    package com.util;
  
  import android.app.AlertDialog;  
  import android.content.Context;  
  import android.content.DialogInterface;  
  import android.content.DialogInterface.OnClickListener;  
  import android.widget.EditText;  
  
  /** 
   * helper for Prompt-Dialog creation 
   */  
  public abstract class PromptDialog extends AlertDialog.Builder implements OnClickListener {  
   private final EditText input;  
  
   /** 
    * @param context 
    * @param title resource id 
    * @param message resource id 
    */  
   public PromptDialog(Context context, int title, int message) {  
    super(context);  
    setTitle(title);
    //:TODO Display msg only if not empty
    //setMessage(message);  
  
    input = new EditText(context);  
    setView(input);  
  
    setPositiveButton("ok", this);  
    setNegativeButton("cancel", this);  
   }  
  
   /** 
    * will be called when "cancel" pressed. 
    * closes the dialog. 
    * can be overridden. 
    * @param dialog 
    */  
   public void onCancelClicked(DialogInterface dialog) {  
    dialog.dismiss();  
   }  
  
   @Override  
   public void onClick(DialogInterface dialog, int which) {  
    if (which == DialogInterface.BUTTON_POSITIVE) {  
     if (onOkClicked(input.getText().toString())) {  
      dialog.dismiss();  
     }  
    } else {  
     onCancelClicked(dialog);  
    }  
   }  
  
   /** 
  
        * called when "ok" pressed. 
        * @param input 
        * @return true, if the dialog should be closed. false, if not. 
        */  
       abstract public boolean onOkClicked(String input);  
      }  
  </code></pre>
  
  <p>and here is the code that i call the instance of the class;</p>
  
  <pre><code>@Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
  
  
  final PromptDialog dlgName = new PromptDialog(this, R.string.enterName, R.string.enter_comment) {  
               @Override  
               public boolean onOkClicked(String input) {  
                // do something 
                mName = input;
                    save();
                            //end do some thing
                return true; // true = close dialog  
               }  
          };      
  
  
      mTxtShiftName = (TextView) findViewById(R.id.shiftname);
              mTxtShiftName.setOnClickListener(new View.OnClickListener() {
              public void onClick(View v) {
                  dlgName.show();
              }   
          });
  </code></pre>