a) setContentView(new content) b) Send an Intent so the OS can resolve it, start a new Activity (optionally restoring it's state), call the needed methods of the old Activity (onPause() etc..) and finally call setContentView(new content) in the new Activity (I know, it's a simplification..)
You need a side-by-side demo for understanding that a is way faster than b? :) Yes, using just one Activity and calling setContentView(new content) is not the best practice but the speed/memory advantage is just too great IMO (yes, I know that I have to handle the back key, state saving and memory cleanup myself.. I'm doing it and it's still way faster/more memory efficent than using different Activities for every screen that I have) If you have a simple application with just a few screens and you don't mind that the user has to wait for about a second while switching between them, then go for many Activities. If you want memory and speed efficiency, then use one Activity and manage the different views yourself (with the burden of managing different states yourself when the user navigates to/away from your app.) On Mon, Oct 27, 2008 at 2:41 PM, Peli <[EMAIL PROTECTED]> wrote: > > Hm, if you have a side-by-side demo comparing the two approaches and > showing that one is really much faster than the other while offering > same functionality, this calls for explanation from the Google > folks :-) To be fair this comparison should be made on a real device > though, not on the emulator. > > Peli > > On Oct 27, 12:36 pm, "Robert K." <[EMAIL PROTECTED]> wrote: >> On the emulator, each sample unit of 'API Demos' is made as single >> Activity. It lasts about 1000-1200 milliseconds till a unit starts. >> >> I don't think this is by design, but simply because it lasts that long >> to load the activity... with setContentView(View) the new screen >> appears almost immediately. >> >> That's what I mean. >> >> Regards, >> Robert > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

