I have three LinearLayout
views where I load some of my own views like that:
linearLayout1.addView(view11);
linearLayout1.addView(view12);
linearLayout2.addView(view21);
linearLayout2.addView(view22);
linearLayout3.addView(view31);
linearLayout3.addView(view32);
The problem is that when I have to load many views (more than 30) the performance drops. Specifically, this happens:
I start the activity, the activity is rendered, I load from the local sqlite the required data to load on screen and I start to add my custom views to the linear layouts.
At that point, the app freeze and after 2-3 seconds, all my custom views appear all together.
I tried putting a Log
inside each custom view's onMeasure
and I found out that each view is indeed ready almost at the same time (<1ms difference between them).
I am looking for a way to know when everything is ready and the user is able to interact with the UI again.
Specifically, I want to show a ProgressDialog
when the activity starts and hide it after those 2-3 seconds, when the screen is ready for the user.
Any ideas?
Also, would it help the overall performance if I replace my LinearLayouts
with ListViews
and add Custom Adapters to add my custom views instead of using addView
?