Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fragment to fragment transaction is slow

I have one fragment with ListView at left side of Screen... whenever user clicks on any item of ListView i show fragment at right side ..

Below is how I am using transaction:

FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
SiteDetailsFragmentActivity fragment = new SiteDetailsFragmentActivity();
fragment.setArguments(args);
fragmentTransaction.replace(R.id.fragment1, fragment);
fragmentTransaction.commit();

Why ds transaction is slow?

like image 268
Balwinder SIngh Avatar asked Sep 12 '14 10:09

Balwinder SIngh


1 Answers

There are some tips may be useful.

  • if you have lots of work like network calls in your fragment try to call them after your onCreateView() function. i.e you can use onStart() or onResume() functions.Also, try to use multiThread.

  • if you have Image Loading try to reduce image qualities or its size.reduce image size

  • Also avoid animation in replacing your fragments.

    FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    
like image 127
behrad Avatar answered Oct 13 '22 10:10

behrad