Here's the deal: I have a heavy layout that cannot be improved any further, as it contains LinearLayouts with weights (so I cannot use RelativeLayouts). In Activity A, I click on a list item that fires off Activity B. Activity A freezes until Activity B is fully loaded, then Activity B gets shown. So this is the complete queue of events:
- Activity A: open B
- Activity A: freezes
- Activity B: finishes inflation/setContentView
- Activity A: goes back into the application stack
- Activity B: gets shown
How can I immediately show Activity B so that Activity A won't freeze? I thought about inflating a temporary layout in B, but I need a callback method that tells me that B is fully visible and I can then replace the temporary layout with the real one.
C开发者_Go百科an anyone help me? Thank you!
Off topic: layout inflation in Android is a real pain, it shouldn't block the whole UI, but it does. Same thing for setting list adapters.
You should do your time taking task of Activity B in thread and if you need to update the UI after your task completes then do it using handler.
You can do your time consuming loading using AsyncTask .You can use
doInBackgroundMethod to load the data
onProgressUpdate you can bind your layout to data.
If you works this way your Activity will not be frozen
精彩评论