My activity have some fragments in a linearLayout (R.id.liste, inside a scrollView) and it takes some time to show. I reduced the size of the array to 50 but it was first 350. Each fragment is independent since I need them to respond to click and to pop a dialog up.
Here is the code :
long start= System.currentTimeMillis();
for (Item item : dao.getList(triKey, start, end)) {
ItemFragment fragment = ItemFragment.newInstance(item);
FragmentTransaction fragTransaction = fragMan.beginTransaction();
fragTransaction.add(R.id.liste, fragment);
fragTransaction.commit();
}
long time = System.currentTimeMillis()-start;
Real question :
I would like to show a circle progressBar and set it Gone when all fragments are shown, but Activity doesn't have a onViewCreated() method, is there any workaround ?
Deeper, theoric question :
If I override Activity.onCreateView() and use the System.currentTimeMillis(), I see that it takes 7.5 seconds to show 50 fragments on my Nexus 4 (and 20s for 350 fragments). Since each fragment only holds 5 TextViews and 1 ProgressBar and takes like 10-15ms to create its view, I'm surprised it takes so long, why does it take nearly 6x more time to add the fragment than to draw it ?
I dont know which piece of code you would need to answer, feel free to ask of course !
Thank you very much for any help !