android - How to update activity when dialog is closed -
i creating custom dialog class in extend default dialog. doing work there. once user closes dialog, how can activity know dialog closed , time update screen views results?
do pass instance activity dialog class can call public method on it? or there better design?
thank you
what i'll this:
- create interface, example: ondialogcloselistener, method called ondialogclose()
- the activity have implement interface , override ondialogclose() method
create attribute in yout dialog class of ondialogcloselistener type , constructor method , when create dialog pass activity parameter.
ondialogcloselistener listener; public mydialog(ondialogcloselistener listener) { this.listener = listener; }
now in onclick method of close button of dialog call method of interface. ex.:
listener.ondialogclose();
and in activity class in method override ondialogcloselistener whatever want when dialog close.
note: can create methods want in interface call each 1 whatever want, not when dialog close, may have other events want check when raised.
hope can you