title: java.lang.NullPointerException:at android.widget.PopupWindow.setContentView when trying to inflate Layout
body: <p>I am trying to show a pop up window after an Image button is clicked. I created an additional layout for the pop up window and used the LayoutInflater to create a view from the layout. I am setting the popup window with this view using "setContentView"</p>
  
  <pre><code> PopupWindow popupWindow = new PopupWindow();   
   LayoutInflater popupLayoutInflater = (LayoutInflater)    getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View popupWindowView = null;
  
          try{
              popupWindowView = popupLayoutInflater.inflate(R.layout.popuplayout, null);
          }
          catch(InflateException e){
              System.out.println(e.getMessage());
          }
  
          if(popupWindowView!=null)
              popupWindow.setContentView(popupWindowView);
          popupWindow.showAtLocation(parentView, android.view.Gravity.NO_GRAVITY, 10, 10);
      }
  </code></pre>
  
  <p>I get the following NullPointerException as the inflate function is returning a null. </p>
  
  <pre><code>05-29 00:20:08.582: W/dalvikvm(304): threadid=1: thread exiting with uncaught exception     (group=0x4001d800)
  05-29 00:20:08.592: E/AndroidRuntime(304): FATAL EXCEPTION: main
  05-29 00:20:08.592: E/AndroidRuntime(304): java.lang.NullPointerException
  05-29 00:20:08.592: E/AndroidRuntime(304):  at     android.widget.PopupWindow.setContentView(PopupWindow.java:377)
  05-29 00:20:08.592: E/AndroidRuntime(304):  at android.widget.PopupWindow.&lt;init&gt;(PopupWindow.java:279)
  05-29 00:20:08.592: E/AndroidRuntime(304):  at android.widget.PopupWindow.&lt;init&gt;(PopupWindow.java:259)
  05-29 00:20:08.592: E/AndroidRuntime(304):  at android.widget.PopupWindow.&lt;init&gt;(PopupWindow.java:216)
  </code></pre>
  
  <p>I am not sure where I am going wrong. Please help</p>