setContentView taking long time (10-15 seconds) to execute

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2011-11-18T09:10:51Z Indexed on 2012/10/15 23:03 UTC
Read the original article Hit count: 77

Filed under:
|

I have a large activity that contains 100 or more buttons. But it's working fine once loaded. Problem however is loading. From clicking its launch icon to getting the first view it takes 10-12 seconds. Until the first view, it shows gray title bar in black background.

At least, I want to show a simple progress bar or dialog while its loading. But it seems like you cannot show anything before setContentView executed. I think I have tried everything I could without any success. If you can give me any hint or idea, I would be thankful.

UPDATE:

I found a dramatic resolution. It takes now a second to load the view. I didn't use splash, thread or async task at all - BTW, don't try to use thread or async on UI because Android UI is not thread-safe. Problem was that those buttons were based on a custom class that requires initialization to load same resource. - so 100 or more file operations were happening on setContentView. Making them a just single loading solved my problem.

© Stack Overflow or respective owner

Related posts about android

Related posts about user-interface