title: Unable to fetch message from EditText in Customized AlertDialog
body: <p>I have created a custom layout for AlertDialog which contains a EditText. The Alertdialog has 2 buttons one for Submit and other for Cancel. When I click submit, I want to fetch the message from EditText and display in Logcat. I am getting a NullPointerException when I click Submit button. Somehow I am failing to fetch the message. Please point out where am I going wrong?</p>
  
  <p>custom Layout file: dialog_reportbug</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;EditText
          android:id="@+id/reportbug"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:ems="10"
          android:hint="@string/reportbug"
          android:inputType="textMultiLine" &gt;    
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And here is the code in my java file:</p>
  
  <pre><code>LayoutInflater inflater = getLayoutInflater();
          View dialoglayout = inflater.inflate(R.layout.dialog_reportbug, null);
          AlertDialog.Builder builder = new AlertDialog.Builder(this);
          builder.setTitle("Bug Report")
          .setCancelable(true)
          .setView(dialoglayout)
          .setPositiveButton("Submit", new DialogInterface.OnClickListener() {
  
              @Override
              public void onClick(DialogInterface dialog, int id) {
                  EditText report = (EditText) findViewById(R.id.reportbug);
                  String msg = report.getText().toString();
                  Log.d("Msg",msg);
              }
          })
          .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  
              @Override
              public void onClick(DialogInterface dialog, int id) {
                  // do something
  
              }
          });
          builder.show();
  </code></pre>