title: android remove view from alertdialog
body: <p>Hi i have a MainActivity class where i have a listview populated by rss items. When i click on item list my app shows me an alertdialog where i can see in message box the item details. My problem is that after i show alertdialog when i close it and open a new item my app crashes giving me this error:</p>
  
  <pre><code>FATAL EXCEPTION: main.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  </code></pre>
  
  <p>Here my java class:</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          listview = (ListView) findViewById(R.id.listView);
  
          wv = new WebView(this);
  
          try {
              url = new URL("http://www.unikore.it/index.php/ingegneria-informatica-home?format=feed");
          } catch (MalformedURLException e) {
              e.printStackTrace();
          }
  
          new ReadRssTask().execute(url);
  
          listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position,long id) {
                  OptionDialog = new AlertDialog.Builder(MainActivity.this).create();
                  OptionDialog.setTitle(listview.getItemAtPosition(position).toString());
                  s = rssItems.get(position).getDescription();
                  if(s.contains("href=")){
                      s.substring(0,s.indexOf("&lt;/div&gt;"));
                      wv.loadData(s, "text/html", "UTF-8");
                      wv.setWebViewClient(new WebViewClient() {
                          @Override
                          public boolean shouldOverrideUrlLoading(WebView view, String url) {
                              view.loadUrl(url);
                              return true;
                          }
                      });
                      OptionDialog.setView(wv);
                  }else {
                      OptionDialog.setMessage(s.replaceAll("&lt;[^&gt;]*&gt;", ""));
                  }
                  OptionDialog.show();
              }
          });
      }
  </code></pre>
  
  <p>i tried using <code>OptionDialog.dismiss()</code> method but app crashes anyway.</p>
  
  <p>Thanks</p>