I have come across to see that ProgressDialog is now deprecated. What would be alternate one to use in place of that apart from ProgressBar.
I am
Yes, ProgressDialog is deprecated but Dialog isn't.
You can inflate your own XML file ( containing a progress bar and a loading text) into your dialog object and then display or hide it using the show() and dismiss() functions.
Here is an example (Kotlin):
ProgressDialog class:
class ProgressDialog {
companion object {
fun progressDialog(context: Context): Dialog{
val dialog = Dialog(context)
val inflate = LayoutInflater.from(context).inflate(R.layout.progress_dialog, null)
dialog.setContentView(inflate)
dialog.setCancelable(false)
dialog.window!!.setBackgroundDrawable(
ColorDrawable(Color.TRANSPARENT))
return dialog
}
}
}
XML
In your code:
Just do var dialog = ProgressDialog.progressDialog(context)
To show: dialog.show()
To hide: dialog.dismiss()