This is an observation I made while using findViewById() for views
which I had made dynamically(they were not in a layout file). I had
made these views in onCreate() of Activity, and set their top-level
parent view as the content of the Activity thorugh setContentView()
within the onCreate() method.

When I tried to search a view by parentView.findViewById(id), I
sometimes got null. But whenever I tried to search them through
activity.findViewById(id) - I was always able to get the View object.
I was earlier assuming parentView.findViewById(id) should always
return the child View - however, perhaps the fact that these Views are
not created through a layout file is causing these quirks.

Just posting it here, for the benefit of others who may be trying to
find a  dynamic view by its Id. If anybody has had other experiences
in this regard, please let me know.

Thanks,
Priyanka

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe, reply using "remove me" as the subject.

Reply via email to