简体   繁体   English

在onRetainNonConfigurationInstance()的帮助下将位图保留在内存中

[英]Keeping a bitmap in memory with the help of onRetainNonConfigurationInstance()

I have a large bitmap that i would like to keep in memory when the qwerty keyboard is visible. 我有一个很大的位图,当qwerty键盘可见时,我想保留在内存中。 My app is always in landscape, so this is the only configuration change that will cause a reDraw. 我的应用程序始终处于横向状态,因此这是唯一会导致重新绘制的配置更改。 I heard this is what onRetainNonConfigurationinstance() is for...but cant figure it out. 我听说这是onRetainNonConfigurationinstance()的目的……但无法弄清楚。 Can someone point me in the right direction? 有人可以指出我正确的方向吗? Thanks. 谢谢。

try 尝试

    @Override
public Object onRetainNonConfigurationInstance() {
    return bitMap;
}

in onCreate call getLastNonConfigurationInstance(); 在onCreate调用getLastNonConfigurationInstance(); to recive the bitmap 重新获取位图

I hade a smilare read about it Save cache when rotate device 我有一个笑脸阅读关于旋转设备时保存缓存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM