Code Droid
Code Droid

Reputation: 10472

Examining the Android View Hierarchy at Runtime in Debug mode?

I'm in an activity and I can't find a particular view. ie findViewById(R.layout.someId) is returning null. So I would just like to see for the current activity what the actual view hierarchy is at runtime. How can I do this?

Upvotes: 4

Views: 1983

Answers (2)

Anne Gunn
Anne Gunn

Reputation: 2447

This perfectly well-worded question has been down-voted for reasons I cannot understand.

And the perfectly straightforward answer:

Yes, you can use the SDK HierarchyViewer tool to see your whole layout tree at runtime

is hidden behind a youtube link that keeps getting poked into answers that say something else or comments to the original question.

Here's a link to the current documentation for HV: https://developer.android.com/tools/debugging/debugging-ui.html

Note that the YouTube video says this can only be used with the app running in the emulator but the documentation says it will also work on "devices running a developer version of the Android system." I certainly don't run my own Android phone, which I use for most of my dev testing, with a dev version of the OS, so I think the YouTube video is effectively correct if not technically correct.

Upvotes: 2

EGHDK
EGHDK

Reputation: 18130

I believe findViewById requires a parameter of R.id.someid and it cannot take layouts. For a layout you must use setContentView(R.layout.someId);

http://www.youtube.com/watch?v=PAgE7saQUUY

Upvotes: -1

Related Questions