show ProgressDialog - Android User Interface

Android examples for User Interface:ProgressDialog

Description

show ProgressDialog

Demo Code


//package com.java2s;
import android.app.Activity;
import android.app.ProgressDialog;

public class Main {
    public static ProgressDialog showDialog(Activity context,
            String strContent) {/*from ww w .  ja  v  a2  s .c  om*/
        if (context != null) {
            ProgressDialog infoDialog = new ProgressDialog(context);
            infoDialog.setMessage(strContent);
            infoDialog.show();
            return infoDialog;
        }
        return null;
    }

    public static ProgressDialog showDialog(Activity context,
            String strContent, int max) {
        if (context != null) {
            ProgressDialog dialog = new ProgressDialog(context);
            dialog.setMessage(strContent);
            dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
            dialog.setMax(max);
            dialog.setProgress(0);
            dialog.show();
            return dialog;
        }
        return null;
    }
}

Related Tutorials