Android examples for User Interface:ProgressDialog
Creates a spinner progress dialog.
import android.app.AlertDialog; import android.app.Dialog; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.view.View; public class Main{ /**//w w w . j ava 2 s . c o m * Creates a spinner progress dialog. * * @param context the context * @param messageId the progress message id * @param onCancelListener the cancel listener */ public static ProgressDialog createSpinnerProgressDialog( Context context, int messageId, DialogInterface.OnCancelListener onCancelListener) { return createProgressDialog(true, context, messageId, onCancelListener); } /** * Creates a progress dialog. * * @param spinner true to use the spinner style * @param context the context * @param messageId the progress message id * @param onCancelListener the cancel listener * @param formatArgs the format arguments for the message id */ private static ProgressDialog createProgressDialog(boolean spinner, Context context, int messageId, DialogInterface.OnCancelListener onCancelListener, Object... formatArgs) { ProgressDialog progressDialog = new ProgressDialog(context); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setIcon(android.R.drawable.ic_dialog_info); progressDialog.setIndeterminate(true); progressDialog.setMessage(context.getString(messageId, formatArgs)); progressDialog.setOnCancelListener(onCancelListener); progressDialog .setProgressStyle(spinner ? ProgressDialog.STYLE_SPINNER : ProgressDialog.STYLE_HORIZONTAL); progressDialog.setTitle("Drawing Map"); return progressDialog; } public static Dialog createProgressDialog(MainActivity activity, String string) { // TODO Auto-generated method stub ProgressDialog progressDialog = new ProgressDialog(activity); progressDialog.setCancelable(true); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setIcon(android.R.drawable.ic_dialog_info); progressDialog.setIndeterminate(true); progressDialog.setTitle("Drawing Map"); return progressDialog; } }