title: How to setView in dialog on Android
body: <p>I use below code to setView in dialog:  </p>
  
  <pre><code>LayoutInflater inflater = LayoutInflater.from(this);
  View layout = inflater.inflate(R.layout.mylayout, null);
  TextView MyTextView = (TextView)findViewById(R.id.my_tv);
  MyTextView.setText("test");
  AlertDialog MyDialog;
  AlertDialog.Builder MyBuilder = new AlertDialog.Builder(this);
  MyBuilder.setTitle("title");
  MyBuilder.setView(layout);
  MyDialog = MyBuilder.create();
  MyDialog.show();
  </code></pre>
  
  <p>my_tv is a TextView in mylayout.xml.<br>
  But it occurs NullPointer error at line <code>MyTextView.setText("test");</code>.<br>
  How can I modify it?  </p>