Question Detail

How to create Custom Progress Bar in Android, customize app logo Loader Dialog?

3 years ago Views 964 Visit Post Reply

I am using basic android loader which has Spinner and Text to show Loading message, But i want my Application logo loading DialogBox.

Create a Customize DialogBox or AlertDialog to implement Loading


Thread Reply

The Developer

- 3 years ago

public static void showWaitDialog(Activity act, String message) {
    try {
        if (loaderDialog != null && loaderDialog.isShowing()) {
            loaderDialog.dismiss();
            showWaitDialog(act, message);
        } else {
            loaderDialog = new Dialog(act);
            loaderDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
            loaderDialog.setCancelable(false);
            loaderDialog.setContentView(R.layout.loading_layout);
            Objects.requireNonNull(loaderDialog.getWindow()).setBackgroundDrawableResource(android.R.color.transparent);
            ((TextView) loaderDialog.findViewById(R.id.loader_message_ID)).setText(message);
            //time to show your Dialog show
            loaderDialog.show();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

public static void closeWaitDialog() {
    try {
        if (loaderDialog != null) {
            loaderDialog.dismiss();
            loaderDialog = null;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}