title: Android How to find and set the content view in a DialogFragment
body: <p>I am trying to make a custom Loading Dialog.</p>
  
  <pre><code>public class LoadingDialogFragment extends DialogFragment {
  
  String title = "";
  String message = "";
  
  public LoadingDialogFragment() {
  
  }
  
  @Override
  public Dialog onCreateDialog(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      title = getArguments().getString("title");
      message = getArguments().getString("message");
  
      Dialog dialog = new Dialog(getActivity());
      View view = getView().findViewById(R.id.loading_dialog_view);
      dialog.setContentView(view);
      dialog.setCancelable(false);
      dialog.setTitle(title);
  
      return dialog;
  }
  }
  </code></pre>
  
  <p>and here is my xml file which I am trying to load:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/loading_dialog_view"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;ProgressBar
      android:id="@+id/progressBar1"
      style="?android:attr/progressBarStyleLarge"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" 
      android:layout_gravity="center"/&gt;
  </code></pre>
  
  <p></p>
  
  <p>How ever I am getting an error when I try to get my view my application crashes.</p>
  
  <p>I call this dialog fragment like so:</p>
  
  <pre><code>    public void showLoadingDialog(String title, String message) {
      loadingDialogFragment = new LoadingDialogFragment();
      Bundle args = new Bundle();
      args.putString("title", title);
      args.putString("message", message);
      loadingDialogFragment.setArguments(args);
      loadingDialogFragment.show(fragManager, "loadingDialog");
  }
  
  public void dismissLoadingDialog() {
      if (loadingDialogFragment != null) {
          loadingDialogFragment.dismiss();
      }
  }
  </code></pre>
  
  <p>How can I set the content view of my Dialog in the DialogFragment?</p>
  
  <p>ERROR:</p>
  
  <pre><code>04-02 21:07:49.156: E/AndroidRuntime(3390): FATAL EXCEPTION: main
  04-02 21:07:49.156: E/AndroidRuntime(3390): java.lang.NullPointerException
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at com.example.rhino68mobileapp.ConnectingActivity.OnError(ConnectingActivity.java:96)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at com.example.rhino68mobileapp.ConnectingActivity$1.onFailure(ConnectingActivity.java:79)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at com.loopj.android.http.AsyncHttpResponseHandler.handleMessage(AsyncHttpResponseHandler.java:373)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at com.loopj.android.http.AsyncHttpResponseHandler$ResponderHandler.handleMessage(AsyncHttpResponseHandler.java:135)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at android.os.Handler.dispatchMessage(Handler.java:99)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at android.os.Looper.loop(Looper.java:137)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at android.app.ActivityThread.main(ActivityThread.java:4424)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at java.lang.reflect.Method.invokeNative(Native Method)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at java.lang.reflect.Method.invoke(Method.java:511)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  04-02 21:07:49.156: E/AndroidRuntime(3390):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>