Search code examples
androidperformanceandroid-fragmentsfragmentstatepageradapter

How modify Adapter Data Withoud Calling notifyDataSetChanged


I have a FragmentStatePagerAdapter, and it have a lot of "pages", that may be added or removed by the user.

When an page gain focus, it have to load it contents from the database. My problem is when the adapter have 2 pages or more , and add a new page i have to call notifyDataSetChanged who reload all "pages"(fragments), and the application begins to run slow.

There a way do add and remove content to an adapter without calling notifyDataSetChanged ?


Solution

  • i found the awnser here:

    Make sure your ViewPager declaration has not a layout_width="0dip".

    FragmentStatePagerAdapter instanciates all fragments after updating to ADT 22