Prevent next fragment (tab) from preload with ViewPager

I am developing an app in Android using Fragments. I have this three tabs:

用户应用截图

I know that is not possible to prevent the load of one fragment on each side (previous and next) as far as the minimum value of setOffScreenPageLimit() is 1 but does it mean that if I want to show a ProgressDialog on the onPreExecute method of an AsyncTask running within Descargas Fragment this will cause that when I nav to the Capturador that ProgressDialog will be necessarily loaded? If yes I have no idea of how to let the user know that I am downloading the packages (that's what Descargas does, to parse some XML).

Thanks in advance ;)


Embed a ProgressBar on the Descargas fragment. Or overlay an indeterminate progressbar over the center of the fragment while it loads.

Dialogs are really part of the activity, it wouldn't make sense that it's only applicable to one of the pages.

At the end of the day though if you must insist on using dialogs, you can implement an onPageChangeListener

viewPager.setOnPageChangeListener(OnPageChangeListener);

And you can pull up the appropriate dialog when the designated fragment is selected and the opposite when you navigate away.

链接地址: http://www.djcxy.com/p/62354.html

上一篇: 我如何从通过USB连接的相机读取文件

下一篇: 防止使用ViewPager预加载下一个片段(制表符)