just like this:

when you click the button of the Dialog A,

Dialog B is showing,and Dialog A is closed.

Then you click the button of the Dialog B,

Dialog A is showing,and Dialog B is closed .