开发者

Android viewpager, control which views to re-render

my viewpager currently only re-renders views that are two views away from what is visually seen.

example (shown respectively)

ViewA, ViewB, CurrentView, ViewD, ViewE


not rendered, rendered, rendered, rendered, not rendered`

how would I force it to reload a particular view X many views away from the currentView, there are some use case scenarios where I want it to, and oth开发者_运维问答er cases when I dont want it to. But currently I only know how to reload the entire adapter - where it perhaps pulls from an arraylist

I'm really not sure how to control the Viewpager - very few examples out there. All I know how to do is reset the entire list on "notifyDataSetChanged"

insight appreciated


use this method mViewPager.setOffscreenPageLimit(2) and you can set the limit of offscreen pages


I think your going too need to decouple your view and data logic (array list in this case?). If you don't want the view to change, don't change the data layer. When you call notifyDataSetChanged everything will mimic your data layer. If you want a view to change, change the data layer and call notifyDataSetChanged.

To put it simpler, the view just draws what the data tells it to, and expect that the view could update at any time. It is very similar to how listview works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜