Android的片段:回收位图 [英] android fragment: recycle bitmap

查看:273
本文介绍了Android的片段:回收位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 DialogFragment 从兼容包。我有一个位图,我需要在对话框关闭时回收,但是当我打电话 findViewByID() onDestroyView()则返回null。我也试图保持到视图的引用从 onCreateView()但它也是空的时候 onDestroyView()被调用。

I am using a DialogFragment from the compatibility package. I have a Bitmap which I need to recycle when the dialog closes, but when I call findViewByID() inside onDestroyView() it returns null. I have also tried keeping a reference to the view from onCreateView() but it is also null by the time onDestroyView() is called.

我怎么能回收位图的一个 DialogFragment 当片段关闭?

How can I recycle a bitmap in a DialogFragment when the fragment closes?

推荐答案

onDestroyView()允许片段清理与显示有关的资源,尝试在onDismiss或在onDestroyView之前调用其他方法来回收位图

onDestroyView() allows the fragment to clean up resources associated with its View, try to recycle bitmap in onDismiss or in other method that called before onDestroyView

这篇关于Android的片段:回收位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆