Code example for ProgressDialog

Methods: setButtonsetTitlesetMessagesetProgresssetProgressStyle, getWindow, setCancelMessage, setCancelable, setCanceledOnTouchOutside, show

0
    } 
 
    public synchronized void show(final Context context, final String title, final String message, final int style, final Message cancelMessage) {
        if (dialog == null) {
            createProgressDialog(context, title, message, cancelMessage);
            dialog.setProgressStyle(style);
            dialog.show();
        } 
    } 
 
    private void createProgressDialog(Context context, String title, String message, Message cancelMessage) {
        if (hideAbsolute) {
            dialog = new CustomProgressDialog(context);
        } 
        else { 
            dialog = new ProgressDialog(context);
        } 
        dialog.setTitle(title);
        dialog.setMessage(message);
        if (cancelMessage != null) {
            dialog.setCancelable(true);
            dialog.setCancelMessage(cancelMessage);
            dialog.setButton(DialogInterface.BUTTON_NEGATIVE, context.getResources().getString(android.R.string.cancel), cancelMessage);
        } else { 
            dialog.setCancelable(false);
        } 
        dialog.setProgress(0);
        dialog.setCanceledOnTouchOutside(false);
        dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        this.progress = 0;
    } 
 
    public synchronized void setMessage(final String message) {
        if (dialog != null && dialog.isShowing()) {