Kotlin Shows Loading Indicator (KSLI)

Is there a better way to display the loading process or progress while waiting for a server response other than using a spinner?

Can it also be done programmatically? so that I don't have to add the spinner component in the xml file.

By the way, spinner has its own meaning in Android, meaning there is a certain relevance when using the component. Understand more by reading the documentation  HERE .

But if you really want to look different, you can use this.

ProgressDialog progress = new ProgressDialog(this);
progress.setTitle("Loading");
progress.setMessage("Wait while loading...");
progress.setCancelable(false); // disable dismiss by tapping outside of the dialog
progress.show();
// To dismiss the dialog
progress.dismiss();


Or this.

ProgressDialog.show(this, "Loading", "Wait while loading...");

Note: ProgressDialog is deprecated for android OREO version, please use ProgressBar instead!

 

Creating Anti-Dismiss Dialog Progress

Just use the following function

progressDialog.setCanceledOnTouchOutside( false );

Post a Comment

Previous Next

نموذج الاتصال