title: Problems creating a Popup Window in Android Activity
body: <p>I'm trying to create a popup window that only appears the first time the application starts. I want it to display some text and have a button to close the popup. However, I'm having troubles getting the PopupWindow to even work. I've tried two different ways of doing it:</p>
  
  <p>First I have an XML file which declares the layout of the popup called popup.xml (a textview inside a linearlayout) and I've added this in the OnCreate() of my main Activity:</p>
  
  <pre><code>PopupWindow pw = new PopupWindow(findViewById(R.id.popup), 100, 100, true);
      pw.showAtLocation(findViewById(R.id.main), Gravity.CENTER, 0, 0);
  </code></pre>
  
  <p>Second I did the exact same with this code:</p>
  
  <pre><code>final LayoutInflater inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      PopupWindow pw = new PopupWindow(inflater.inflate(R.layout.popup, (ViewGroup) findViewById(R.layout.main) ), 100, 100, true);
      pw.showAtLocation(findViewById(R.id.main_page_layout), Gravity.CENTER, 0, 0);
  </code></pre>
  
  <p>The first throws a NullPointerException and the second throws a BadTokenException and says "Unable to add window -- token null is not valid"</p>
  
  <p>What in the world am I doing wrong? I'm extremely novice so please bear with me.</p>