How to put Progress dialog in seperate class and call in every activity in android? -
i have progress dialog in every activity , in every activity write code progress dialog different message want.is there way put progress dialog code in seperate class , call class in activity want show progress dialog.
here code progress dialog:-
progressdialog m_dialog = new progressdialog(cloginscreen.this); m_dialog.setmessage("please wait while logging..."); m_dialog.setprogressstyle(progressdialog.style_spinner); m_dialog.setcancelable(false); m_dialog.show();
you can define class
encapsulate operation , maybe other involving dialogs. use class
static
methods, this:
public class dialogsutils { public static progressdialog showprogressdialog(context context, string message){ progressdialog m_dialog = new progressdialog(context); m_dialog.setmessage(message); m_dialog.setprogressstyle(progressdialog.style_spinner); m_dialog.setcancelable(false); m_dialog.show(); return m_dialog; } }
in activity class:
progressdialog mydialog= dialogutils.showprogressdialog(this,"some message"); ... mydialog.dismiss();
of course can add others parameters operation can more flexible.
hope helps.
Comments
Post a Comment