OutOfMemoryError on ViewPager

▼魔方 西西 提交于 2019-12-12 22:31:34

问题


I'm using a ViewPager with 13 pages. It is managed using a FragmentStatePagerAdapter, and each page loads 250ko images as backgrounds, and sometimes 5 images more per page.

I get extremely often an OutOfMemoryError error and I'm testing my app on a Samsung Galaxy Tab 2, so I guess I'm doing something wrong.

Is there a way to release images which are not used on the life cycles of my Fragments on the ViewPager? Any other idea?

Thanks in advance.


回答1:


Everything is very well explained and detailed on Displaying Bitmaps in Your UI




回答2:


Setting up the android:largeHeap to true is also extremely useful for this kind of problems.



来源:https://stackoverflow.com/questions/11446687/outofmemoryerror-on-viewpager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!