findViewById -observation for dynamic Views (not created using layout file)

by priyanka » Mon, 12 Apr 2010 15:59:26 GMT

Sponsored Links
 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.



Other Threads

1. OpenCORE on Cupcake

I happen to find that OpenCORE on cupcake tree is still an older version
rather than v2.x.
1. Will v2.x be merged to cupcake tree recently?
2. If I simply replace the old folder with v2.x external/opencore folder,
will it work?



2. Anything on Android that can do smooth scrolling?

The trick is simple: avoid any allocation that might trigger a GC.

On Wed, Mar 25, 2009 at 1:18 PM,

Romain Guy
Android framework engineer

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them


3. How to return non-table-oriented data from a content provider

4. How to return non-table-oriented data from a content provider

5. Do Android devs work on Android products full time or part time?

6. Please suggest Substitute for drawRegion in android.

7. Reconnect adb while emulator is running