I have to display many error messages and alert dialogues in my application.
I do not want to use Toast, I prefer to use AlertDialog
.
Instead of creating a new alert dialog in every activity, how do I create and maintain one alert dialog and just change the error message string in it?
Whatever activity I am in, I must be able to access the AlertDialog
instance to show and dismiss it.
How can I achieve this? Kindly give me some lead on this.
make one class and paste this function...(may be Utils.java)
and call this by writing..
You could always write a base class of Activity with your alertdialog call as a method and then for any of your activity classes instead of using extends Activity, use extends MyBaseActivity and then call the method whenever you need it by passing the string you want output.
Try this:
You can make this class's object anywhere in your application as,
And call method
showValidationDialog
according to your needI do something like this in a helper class