简体   繁体   English

带有asynctasks的Android Viewpager(页面加载时的微调器)

[英]Android Viewpager with asynctasks (spinner while page is loading)

I want a Viewpager that shows loading while content is coming in from the background. 我想要一个Viewpager,它显示内容从后台进入时的加载。 Basically I expect the first View to be loaded, but View+1 and View-1 will still be loading. 基本上我希望加载第一个View,但仍然会加载View + 1和View-1。 If the user swipes to either side I want them to be presented with a spinning dialog while it loads 如果用户向任一侧滑动,我希望它们在加载时显示旋转对话框

Would I just add AsyncTasks into the ViewPager with some conditions determining when they will run? 我是否只是将AsyncTasks添加到ViewPager中,并确定它们何时运行? I dont want too many AsyncTasks to be loading as the viewpager will have many views off to the sides. 我不希望加载太多的AsyncTasks,因为viewpager会向侧面提供许多视图。

I think the Trulia app does this, it is similar to what I am looking for. 我认为Trulia应用程序可以做到这一点,它与我正在寻找的类似。 Apartment image viewing shows a loading screen while the images are loading in that viewpage. 在该视图页面中加载图像时,公寓图像查看显示加载屏幕。

Also for the record, can I just treat viewpagers like onCreate functions of an activity? 另外,对于记录,我可以像处理活动的onCreate函数一样对待查看者吗? That would really clear things up 这真的可以解决问题

Insight appreciated 洞察力赞赏

如果要对每个页面执行更多类似于Activity的生命周期管理,请查看提供的FragmentPagerAdapter。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM