title: How to start activity from a popup window?
body: <p>I have a custom popup window with it's own layout in my activity (code that responsible for the work of the popup window is in a separate class PopupWindowActivity). I want to appoint a button in this popup window opening activity. I tried some methods but app crashed with NullPointerException.</p>
  
  <p>The code of this activity is following:</p>
  
  <pre><code>public class FirstActivity extends Activity implements OnClickListener {
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      ImageView popupButton = (ImageView) this.findViewById(R.id.popup_btn);
      likemenuButton.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              PopupWindow dw = new PopupWindow(v);
              dw.showLikePopDownMenu();
          }
      });
  }
  
      // my stuff
  
  
  
  //popup window
  private class PopupWindow extends PopupWindowActivity implements OnClickListener {
      public PopupWindow(View anchor) {
          super(anchor);
      }
  
      @Override
      protected void onCreate() {
          // inflate layout
          LayoutInflater inflater =
                  (LayoutInflater) this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          ViewGroup root = (ViewGroup) inflater.inflate(R.layout.popup, null);
  
          // setup button events
          ImageView aboutButton = (ImageView) findViewById(R.id.btn_about);
          aboutButton.setOnClickListener(this);
  
          this.setContentView(root);
      }
  
      @Override
      public void onClick(View v) {
  
          switch (v.getId()) {
          case R.id.btn_about: {
          Intent activity = new Intent(FistActivity.this, About.class);
          startActivity(activity);
          break;
          }
  
      }
  }}
  </code></pre>
  
  <p>}</p>
  
  <p>In another way:</p>
  
  <pre><code>private static class PopupWindow extends PopupWindowActivity implements OnClickListener {
          public PopupWindow(View anchor) {
          super(anchor);
      }
  
      @Override
      protected void onCreate() {
          // inflate layout
          LayoutInflater inflater =
                  (LayoutInflater) this.anchor.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  
          ViewGroup root = (ViewGroup) inflater.inflate(R.layout.popup, null);
  
          // setup button events
          ImageView searchButton = (ImageView) findViewById(R.id.btn_about);
          algebraButton.setOnClickListener(this);
  
  
          this.setContentView(root);
      }
  
      @Override
      public void onClick(View v) {
          switch (v.getId()) {
          case R.id.btn_about: {
              Intent intent = new Intent();
              intent.setClass(this, About.class);
  
              startActivity(intent);
              break;
          }
  
          default:
              break;
          }
  }}
  </code></pre>
  
  <p>eclipse says that at first I should delete <code>static</code> from <code>private static class PopupWindow extends PopupWindowActivity implements</code>, then I have following for <code>intent.setClass(this, About.class);</code>:</p>
  
  <p><code>The method setClass(Context, Class&lt;?&gt;) in the type Intent is not applicable for the arguments 
   (FirstActivity.PopupWindow, Class&lt;About&gt;)</code></p>
  
  <p>Please, help.</p>
  
  <hr>
  
  <p>Added log for first crash:</p>
  
  <pre><code>03-07 00:28:07.750: D/AndroidRuntime(12472): Shutting down VM
  03-07 00:28:07.750: W/dalvikvm(12472): threadid=1: thread exiting with uncaught exception (group=0x40018578)
  03-07 00:28:07.759: E/AndroidRuntime(12472): FATAL EXCEPTION: main
  03-07 00:28:07.759: E/AndroidRuntime(12472): java.lang.NullPointerException
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at com.example.FirstActivity$PopupWindow.onCreate(FirstActivity.java:110)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at com.quickaction.PopupWindowActivity.&lt;init&gt;(PopupWindowActivity.java:52)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at com.example.FirstActivity$PopupWindow.&lt;init&gt;(FirstActivity.java:97)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at com.example.FirstActivity$1.onClick(FirstActivity.java:30)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at android.view.View.performClick(View.java:2485)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at android.view.View$PerformClick.run(View.java:9080)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at android.os.Handler.handleCallback(Handler.java:587)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at android.os.Handler.dispatchMessage(Handler.java:92)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at android.os.Looper.loop(Looper.java:130)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at android.app.ActivityThread.main(ActivityThread.java:3687)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at java.lang.reflect.Method.invokeNative(Native Method)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at java.lang.reflect.Method.invoke(Method.java:507)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
  03-07 00:28:07.759: E/AndroidRuntime(12472):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>