In the fragment, inside the onViewCreated function, the new DownloadJSON () function is called. Execute () Now it is executed each time the fragment is called.

How to make new DownloadJSON (). Execute () run only once?

  • How do you create a fragment? Why is this method jerking several times? As an option, try to push this method into the onCreate or onAttach method - Werder
  • Using the SlidingTabLayout and SlidingTabStrip classes, tabs with snippets are created: case 0: fragment = new ScreenOne (); break; case 1: fragment = new Akcii (); break; - Maxim Zeroeff
  • better make singlton fragments - Dennis Zinkovsky

1 answer 1

If you use the Viewpager , then:

 mViewPager = (ViewPager) findViewById(R.id.viewpager); mViewPager.setOffscreenPageLimit(6); //здесь установи количество фрагментов 

Or: Show me the code