Romans Stepanovs
Romans Stepanovs

Reputation: 857

Attaching listener to dialog

I need to be notified when there are changes on the screen. Currently I am using

this.getWindow().getDecorView().getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener()
        {
            @Override
            public void onGlobalLayout()
            {
                Log.d("TAG", "GLOBAL LAYOUT");
            }
        });

But it doesn't work when dialog(custom, alert, progress, etc.) is shown or dismissed. I understand that dialogs are shown on another overlay so listener isn't attached to them. How can I get my desired functionality?

Upvotes: 0

Views: 252

Answers (1)

cafebabe1991
cafebabe1991

Reputation: 5186

You probably need a dialog.setOnDismissListener or dialog.setOnCancelListener

They'll be called when something related to dialog dismissal happens or is being canceled.

Upvotes: 2

Related Questions