It will return the first it finds during a depth-first traversal of the
hierarchy.  The framework uses framework ids -- 0x01nnnnnn.  It is up to you
to generate unique id integers (if you aren't using @id/blah) however you
would like, if needed.  There is no requirement for ids to be unique in a
view hierarchy -- for example items in a list view are from the same view
hierarchy with the same ids, and this is fine even if they use a relative
layout.
On Dec 27, 2010 11:22 AM, "John Lussmyer" <[email protected]> wrote:
> Well, things just aren't quite working that way.
> I had 2 instances of my custom view (subclass of RelativeLayout) on
screen.
> Each of these did have a unique ID number.
> When the children of my view all used the same set of ID numbers
> (900,901,902 for the 3 children of the custom view), then when the main
app
> code called a custom.setValue() method - which just passed the given
string
> on to one of the children childTextView.setText() - it was updating the
> WRONG instances child. (which seemed really weird, since I had the
TextView
> object reference directly from when I programmatically created it.)
> I modified the code so that every instance used a different set of child
ID
> numbers, and this problem went away.
>
> I can hope that the numbers I chose won't conflict with some other custom
> control someday, but if the main app calls findViewById(), and that id
> occurs in both my custom control, and some view that the app defined in
> their XML, which will it find?
>
> On Mon, Dec 27, 2010 at 9:49 AM, Bret Foreman <[email protected]
>wrote:
>
>> The view ID is intended to be used inside the scope of an onClick() or
>> some other onEvent() method. In that case, the onEvent method was set
>> in the initialization for the widget, which will be unique to your
>> widget. In other words, it's always one of your custom widgets. I
>> wouldn't use a view ID outside that scope.
>>
>>
>
> --
> 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]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
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

Reply via email to