4

I have a single activity which has a tabPageIndicator at the bottom of the screen. Please see screenshot. The first four icons need to open other fragments. The final icon needs to open an alert box with options to open other screens.

I am facing two problems:

  1. ViewPager loads all the 4 fragments at once and there is a lot of data being processed in the background. I would like to know if there is any way to load content only when the fragment is visible to user. I tried using setPageLimit but it did not work.

  2. My second problem is that I would like to ideally open a popup when the last icon is clicked, rather than opening another fragment. IS that possible?

I am not sure if viewPager supports view without fragments.

ROMANIA_engineer
  • 54,432
  • 29
  • 203
  • 199
  • Add your activity code – Santosh Kathait Apr 26 '15 at 16:19
  • possible duplicate of [How can make my ViewPager load only one page at a time ie setOffscreenPageLimit(0);](http://stackoverflow.com/questions/19096868/how-can-make-my-viewpager-load-only-one-page-at-a-time-ie-setoffscreenpagelimit) – jenzz Apr 26 '15 at 16:19
  • In viewpager fragments the current and next fragment will load automatically. You can try setting setoffscreenpagelimit(1); or check if the fragment.isVisible() then load the data. – Surender Kumar Apr 26 '15 at 16:19
  • Nope adding setOffScreenPageLimit did not work. –  Apr 26 '15 at 17:08
  • for the popup, how about DialogFragment? – Froyo Apr 26 '15 at 18:19
  • That's actually a neat idea. Never thought of it! But it actually needs to be more like a popup menu. Click on it and a dropdown opens up –  Apr 26 '15 at 18:22
  • Check this [answer](https://stackoverflow.com/a/56056285/7914153) for your first question. – Gopinath May 09 '19 at 09:29

0 Answers0