0

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.

4

3 に答える 3

1

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

于 2012-04-23T08:26:43.823 に答える
1

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

于 2012-04-23T08:30:13.717 に答える
0

You could force the use of Garbage Collector using

System.gc()

于 2012-04-23T08:22:54.427 に答える