ViewPager unable to load images lazily with Picasso

前端 未结 2 1202
没有蜡笔的小新
没有蜡笔的小新 2021-01-17 04:34

I have a FragmentActivity in the first tab of a TabHost, and the FragmentActivity itself holds a ViewPager.

The

相关标签:
2条回答
  • 2021-01-17 05:05

    Your lazy loader should work in the context of the

    Fragment.createView()

    where the Fragment is one of a collection being paged by the ViewPager and the FragmentpagerAdapter

    That is your option one.

    I use another lazyloader that manages local memcache and local filesys cache for the bitmaps needed to load the images. at the time of the "OnCreateView()" it will go to the network to get the URL for the loader if the bitmap is not already cached.

    0 讨论(0)
  • 2021-01-17 05:11

    Your first approach should work fine... if you implement it correctly. I would expect your code to crash with a NullPointerException.

    Replace:

    ImageView imageView = (ImageView)getView().findViewById(R.id.fragment_image);
    

    with:

    ImageView imageView = (ImageView)myFragmentView.findViewById(R.id.fragment_image);
    
    0 讨论(0)
提交回复
热议问题