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.

Thanks,
Priyanka

--



Other Threads

1. Battery Management generic solution

Hi all,

I have studied the battery management implementation of Android, and found that 
in the file "com_android_server_BatteryService.cpp", the ACPI paths are hard 
coded, for example, the AC_ONLINE_PATH is defined as 
"/sys/class/power_supply/ac/online", BATTERY_CAPACITY_PATH is defined as 
"/sys/class/power_supply/battery/capacity". But for every device, the ACPI 
interface is different from each other.
For example, for Compal, AC_ONLINE_PATH is 
"/sys/class/power_supply/ACAD/online", and there is not a path of 
BATTERY_CAPACITY_PATH, but there are two paths for it:
/sys/class/power_supply/BAT1/charge_full
/sys/class/power_supply/BAT1/charge_now

I am creating a generic, configurable solution with defaults configured to be 
compatible with the original solution .

Thanks
Tim
Intel Software Services Group (SSG)

--~--~---------~--~----~------------~-------~--~----~

2. raw resources in worker thread

Hi,
How do I access raw resources in a worker thread?   I have been trying
to use Context.getResources but this seems to create some type of
handler error.

Thanks,
Bob
--~--~---------~--~----~------------~-------~--~----~

3. Music player got crashed in android running on beagle

4. accessing raw resources in worker thread. I have been trying to use Context.getResources but this seems to create some type of handler error.

5. How to get a special layout xml file in another application

6. 24MB in RAW folder -- when running showing "INSTALL_FAILED_INSUFFICIENT_STORAGE"

7. apply color to Button