【问题标题】:Fragment BackStack clears after loading the Image using Glide Image LibraryFragment BackStack 在使用 Glide Image Library 加载图像后清除
【发布时间】:2019-03-25 01:04:31
【问题描述】:

我使用 Glide 进行图像加载(图像在我的片段内)。并在后台处理片段回栈以在片段之间导航。加载图像后,我的片段后台堆栈替换为以下片段

com.bumptech.glide.manager.SupportRequestManagerFragment

entry 所以我现在无法处理 backstack,我不希望将 glide SupportRequestManagerFragment 附加到片段 backstack 中,我也已阅读以下链接中的 glide 文档

http://bumptech.github.io/glide/javadocs/360/com/bumptech/glide/Glide.html#with%28android.support.v4.app.Fragment%29

他们提到传递上下文将根据上下文参数将 Glide 附加到应用程序生命周期。现在我的要求是在不影响fragment backstack的情况下如何使用glide加载图像,有可能吗?或者有没有其他方法可以通过配置 Glide 选项来做到这一点?

有人帮助我或建议解决此问题的方法吗?

【问题讨论】:

    标签: android android-fragments android-glide


    【解决方案1】:

    我已经用 Fragment 上下文加载了 Glide

    这样 com.bumptech.glide.manager.SupportRequestManagerFragment

    附加到后台堆栈,为了避免后台堆栈中的 SupportRequestManagerFragment 条目,我已经使用 getApplicationContext() 加载了 Glide,如下面的 url 中所述。

    http://bumptech.github.io/glide/javadocs/330/com/bumptech/glide/Glide.html#with%28android.content.Context%29

    【讨论】:

    • 谢谢伙计,这对我有用,我已经在片段中添加了 getApplicationContext() 和 getActivity()。
    • 感谢分享您的解决方案,您救了我。谢谢!
    猜你喜欢
    • 2019-02-01
    • 2020-03-24
    • 1970-01-01
    • 2017-09-13
    • 1970-01-01
    • 2016-05-09
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    相关资源
    最近更新 更多