title: Crazy... button.setOnClickListener java.lang.NullPointerException
body: <p>Honestly...I'm getting crazy about this error.. =)) I would pay you a dinner for this one..</p>
  
  <p>I'm having a <strong>java.lang.NullPointerException</strong> in a button. The error, is on the code (MainActivity, function doReport() ):</p>
  
  <pre><code>ReportDialog = new Dialog(this);        
  ReportDialog.setCancelable(true);
  ReportDialog.setContentView(R.layout.report);
  ReportDialog.setTitle("GeoClient Report");
  
  button_report = (Button) findViewById(R.id.button_report);
  
  button_report.setOnClickListener(new OnClickListener() { // line 274 **ERROR** NullPointerException
  @Override
  public void onClick(android.view.View v) {}  });
  </code></pre>
  
  <p>The layout:</p>
  
  <pre><code>&lt;Button
  android:id="@+id/button_report"
  android:layout_width="500dp"
  android:layout_height="wrap_content"
  android:text="Report" /&gt;
  </code></pre>
  
  <p>More details:</p>
  
  <ol>
  <li>I've togglebuttons exactly in the same situation, and they're working... (view is clickable, i guess)</li>
  <li>If I leave uncommented the code button_report = (Button) findViewById(R.id.button_report); and comment // button_report.setOnClickListener(... it works! (therefore, The button is found on the layout)</li>
  <li><p>The layout is called as dialog, the code</p>
  
  <p>ReportDialog = new Dialog(this);<br>
  ReportDialog.setCancelable(true);
  ReportDialog.setContentView(R.layout.report);
  ReportDialog.setTitle("GeoClient Report");</p></li>
  </ol>
  
  <p>Finally the stack:</p>
  
  <pre><code>11-07 02:47:52.179: E/Teste(10730): TOAST: doLogin: A fazer Report!!!
  11-07 02:47:52.519: D/AndroidRuntime(10730): Shutting down VM
  11-07 02:47:52.519: W/dalvikvm(10730): threadid=1: thread exiting with uncaught exception (group=0x417aa930)
  11-07 02:47:52.597: E/AndroidRuntime(10730): FATAL EXCEPTION: main
  11-07 02:47:52.597: E/AndroidRuntime(10730): java.lang.NullPointerException
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.geoclient.MainActivity.doReport(MainActivity.java:274)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.geoclient.MainActivity.onOptionsItemSelected(MainActivity.java:503)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.app.Activity.onMenuItemSelected(Activity.java:2597)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:1031)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.android.internal.view.menu.MenuBuilder.dispatchMenuItemSelected(MenuBuilder.java:735)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:152)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:874)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.android.internal.view.menu.ListMenuPresenter.onItemClick(ListMenuPresenter.java:166)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.widget.AdapterView.performItemClick(AdapterView.java:298)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.widget.AbsListView$1.run(AbsListView.java:3424)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.os.Handler.handleCallback(Handler.java:725)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.os.Handler.dispatchMessage(Handler.java:92)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.os.Looper.loop(Looper.java:137)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at android.app.ActivityThread.main(ActivityThread.java:5227)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at java.lang.reflect.Method.invokeNative(Native Method)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at java.lang.reflect.Method.invoke(Method.java:511)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
  11-07 02:47:52.597: E/AndroidRuntime(10730):    at dalvik.system.NativeStart.main(Native Method)
  11-07 02:47:54.773: I/Process(10730): Sending signal. PID: 10730 SIG: 9
  </code></pre>