Actually it's not nearly so smart -- it is just a traversal through the view hierarchy until it finds a matching id.
As with all things, you should avoid doing this repeatedly if you don't need to (keep the thing you find in a variable so you don't have to look it up again). For more subtle performance questions, the profiler is really what you need to use. On Mon, Apr 13, 2009 at 10:09 AM, Michael Bollmann < [email protected]> wrote: > > I guess findViewById uses some kind of map implementation with O(log > n) > So my guess is that it's about 100-200 compared to 0 when you use > member access. > > On Apr 13, 6:40 pm, Alexey <[email protected]> wrote: > > yeah, that reference doesn't have number i'm looking for. > > > > On Apr 13, 11:20 am, Michael Bollmann > > > > <[email protected]> wrote: > > > It depends on how often you call it and what your app is doing anyway. > > > Now matter how good it's implementation is access to a member variable > > > is always much faster than a function call. > > > On the other hand you might not notice any improvement in case your > > > app does some stuff that takes > > > 1000 times longer than a call to findViewById. > > > > > Take a look at this: > http://developer.android.com/guide/practices/design/performance.html#... > > > > > On Apr 13, 6:04 pm, Alexey <[email protected]> wrote: > > > > > > Hi all, trying to find some performance numbers for findViewById - > > > > need to convince to change bunch of the findViewById for the same > > > > widget to member variable with just one findViewById on create . Or > > > > may be i'm wrong and it's fine ? > > > -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---

