使用PageContainer ViewPager转盘不FragmentPagerAdapter工作 [英] ViewPager carousel using PageContainer not working with FragmentPagerAdapter
问题描述
我使用 https://gist.github.com/8cbe094bb7a783e37ad1 为了在显示一个ViewPager的多页一旦。它用一个简单的PageAdapter的伟大工程,但我需要显示大量的位图。所以,我读<一个href=\"http://developer.android.com/training/displaying-bitmaps/index.html\">http://developer.android.com/training/displaying-bitmaps/index.html和它说:
I'm using https://gist.github.com/8cbe094bb7a783e37ad1 in order to display multiple page of a ViewPager at once. It works great with a simple PageAdapter, but I need to display a large amount of Bitmaps. So I read http://developer.android.com/training/displaying-bitmaps/index.html and it says :
您可以实现使用由PagerAdapter支持的ViewPager组件这种模式。然而,一个更合适的后盾适配器是子类的 FragmentStatePagerAdapter 自动销毁,并为他们消失离屏保存在ViewPager碎片状态,保持内存使用了。
You can implement this pattern using a ViewPager component backed by a PagerAdapter. However, a more suitable backing adapter is the subclass FragmentStatePagerAdapter which automatically destroys and saves state of the Fragments in the ViewPager as they disappear off-screen, keeping memory usage down.
我试图创建一个新的FragmentStatePagerAdapter,但它不工作:
I tried to create a new FragmentStatePagerAdapter but it doesn't work :
E / AndroidRuntime(25400):$ android.content.res.Resources NotFoundException:无法找到资源编号为0xffffffff
E/AndroidRuntime(25400): android.content.res.Resources$NotFoundException: Unable to find resource ID #0xffffffff
我真不明白什么是错误的,因为我没有使用布局以外任何特定的资源。
I really don't understand what's the error, because I'm not using any particular resources except layouts.
有没有人有一个想法如何解决这个问题?
Does anyone have an idea how to resolve this ?
推荐答案
我才发现,它的作品当我添加一个机器人:ID为ViewPager的PageContainer内。所以,只要有一个ID它似乎工作,但我不明白为什么。
I just discover that it works when I add an android:id to the ViewPager inside the PageContainer. So, just with an id it seems to work, but I don't understand why.
如果一个人有一个想法,我会很高兴认识。
If someone have an idea, I'll be glad to understand.
这篇关于使用PageContainer ViewPager转盘不FragmentPagerAdapter工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!