title: How to fix "Avoid passing null as the view root" in android?
body: <p>In my android app, I create a dialog like this:</p>
  
  <pre><code>private void handleEdit() {
      LayoutInflater inflater = getLayoutInflater();
      View dialoglayout = inflater.inflate(R.layout.dialog_gallery, null);
  
      final AlertDialog d = new AlertDialog.Builder(this)
      .setView(dialoglayout)
      .setTitle(R.string.edit)
      .setNegativeButton(R.string.cancel, null)
      .create();
  
      CheckBox mainCB = (CheckBox)dialoglayout.findViewById(R.id.main);
      CheckBox usedCB = (CheckBox)dialoglayout.findViewById(R.id.used);
      mainCB.setChecked(image.getIsMain());
      usedCB.setChecked(image.getApproved());
  
      mainCB.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View arg0) {
              if (Network.isNetworkAvailable(GalleryScreen.this)) {
                  new Async_update_image_state(GalleryScreen.this, fish, image, !image.getIsMain(), image.getApproved(), false);
                  d.dismiss();
              } else {
                  Popup.ShowErrorMessage(GalleryScreen.this, R.string.no_internet, false);
              }
          }
      });
  
      usedCB.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View arg0) {
              if (Network.isNetworkAvailable(GalleryScreen.this)) {
                  new Async_update_image_state(GalleryScreen.this, fish, image, false, !image.getApproved(), true);
                  d.dismiss();
              } else {
                  Popup.ShowErrorMessage(GalleryScreen.this, R.string.no_internet, false);
              }
          }
      });
  
      d.show();
  }
  </code></pre>
  
  <p>But I get a warning on <code>View dialoglayout = inflater.inflate(R.layout.dialog_gallery, null);</code> underlining the <code>null</code>.</p>
  
  <pre><code>Avoid passing null as the view root (needed to resolve layout parameters on the inflated layout's root element)
  </code></pre>
  
  <p>What does this mean and how can I fix it?</p>
  
  <p>Thanks.</p>