Android calling a custom ProgressDialog - how?
<p><a href="http://stackoverflow.com/questions/3225889/how-to-center-progress-indicator-in-progressdialog-easily-when-no-title-text-pas/3226233#3226233">How to center progress indicator in ProgressDialog easily (when no title/text passed along)</a></p>

<p>trying to create a custom progressdialog, but not working..</p>

<p>my code:</p>

<pre><code>public class CustomProgressDialog extends ProgressDialog {

public CustomProgressDialog(Context context) {
        super(context, R.style.progress_dialog);
}

public static CustomProgressDialog show(Context context, CharSequence title,
        CharSequence message) {
    return show(context, title, message, false);
}

public static CustomProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate) {
    return show(context, title, message, indeterminate, false, null);
}

public static CustomProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate, boolean cancelable) {
    return show(context, title, message, indeterminate, cancelable, null);
}

public static CustomProgressDialog show(Context context, CharSequence title,
        CharSequence message, boolean indeterminate,
        boolean cancelable, OnCancelListener cancelListener) {
    CustomProgressDialog dialog = new CustomProgressDialog(context);
    dialog.setTitle(title);
    dialog.setCancelable(cancelable);
    dialog.setOnCancelListener(cancelListener);
    dialog.addContentView(new ProgressBar(context), new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    dialog.show();

    return dialog;
}
}
</code></pre>

<p>and how i d like to call:</p>

<pre><code>public static CustomProgressDialog dialog;

public static void showLoaderDialog(String sHead, String sMess) {
    dialog=new CustomProgressDialog(mycontext).show(mycontext, sHead, sMess, true, true);
}
public static void hideLoaderDialog() {
    dialog.dismiss();
}
</code></pre>

<p>but i get only crash:( why? how can call this custom dialog?</p>

<p>error log:</p>

<pre><code>04-05 20:33:12.754: ERROR/AndroidRuntime(13165): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:174)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.android.internal.app.AlertController.installContent(AlertController.java:201)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.app.AlertDialog.onCreate(AlertDialog.java:260)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.app.ProgressDialog.onCreate(ProgressDialog.java:176)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.app.Dialog.dispatchOnCreate(Dialog.java:307)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.app.Dialog.show(Dialog.java:225)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.lacas.chathuProto.CustomProgressDialog.show(CustomProgressDialog.java:37)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.lacas.chathuProto.CustomProgressDialog.show(CustomProgressDialog.java:26)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.lacas.chathuProto.chathuStart.showLoaderDialog(chathuStart.java:814)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.lacas.chathuProto.chathuPROTO$12.run(chathuPROTO.java:1159)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.os.Handler.handleCallback(Handler.java:587)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.os.Handler.dispatchMessage(Handler.java:92)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.os.Looper.loop(Looper.java:123)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at java.lang.reflect.Method.invokeNative(Native Method)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at java.lang.reflect.Method.invoke(Method.java:521)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-05 20:33:12.754: ERROR/AndroidRuntime(13165):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>
