Israel Unterman
Israel Unterman

Reputation: 13520

PopupWindow dismiss

When I use dismiss to remove a popup window, does it only hide it or removes it from memory?

I tried dismiss, then showAtLocation several times (using the same PopupWindw object, not re-creating it) and the window was displayed and hidden without problems. The question is can I count on it - perhaps it is marked for deletion by the GC, but hasn't been garbage-collected yet?

Thanks.

Upvotes: 0

Views: 1530

Answers (3)

Alexander
Alexander

Reputation: 48272

dismiss() is opposite to showAtLocation(), the object remains in a valid state after dismiss(). So it is safe to toggle dismiss()/showAtLocation()

It can be seen from the Android source code in here - you can look at dismiss() and showAtLocation() implementations

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.5_r4/android/widget/PopupWindow.java#PopupWindow.showAtLocation%28android.view.View%2Cint%2Cint%2Cint%29

http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.5_r4/android/widget/PopupWindow.java#PopupWindow.dismiss%28%29

Upvotes: 1

MByD
MByD

Reputation: 137412

An object will not be marked for deletion as long as you have a reference to it. So you can re-show it later.

Upvotes: 1

Manitoba
Manitoba

Reputation: 8702

You could force the use of Garbage Collector using

System.gc()

Upvotes: 0

Related Questions