0

Android hierarchyviewer shows a ID for each view in the tree view. The ID is a @ sign followed by a number, e.g @4051d698

In android documentation the purpose of this number is explained as "pointer to view object".

Assuming one has the sources of a very big android project like AOSP. How can one figure out what is the java source code behind the view by using this ID?

Is there a method I can invoke that tells me what is the R.java entry that is bound to this pointer?

ApriOri
  • 2,618
  • 29
  • 48

1 Answers1

1

How can one figure out what is the java source code behind the view by using this ID?

You can't, at least without a debugger. If you are used to C/C++ development, that hexadecimal value is roughly analogous to a pointer. Just because you have a pointer to a hunk of RAM in C/C++ does not mean that you can determine the source code behind the object resident at that pointer.

Now, it is possible that there is a way in a debugger to supply this hex value and the debugger will match that up to an object and source code. I am not an Eclipse expert, or an expert on another other IDE debuggers, to know whether or not there is a means to do this. However, even if can do this, it will probably only give you the source of the class of the object (e.g., if the View is a ListView, it might send you to the ListView source code), not the source code of what created the object.

Is there a method I can invoke that tells me what is the R.java entry that is bound to this pointer?

First, R.java is not "bound" to any pointers.

Second, the View in question may not have come from an inflated layout. It might have been created directly in Java code instead.

If the View has an "View object ID" (e.g., id/content), that can better help you find where it came from, as that will be an android:id value, possibly from your layout resources.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • So why hierarchyviewer shows it in the view tree? is there another information i can get from this pointer? according to your explanation it's so minor that a developer shouldn't care from it. – ApriOri Dec 16 '12 at 15:57
  • @ApriOri: "So why hierarchyviewer shows it in the view tree? is there another information i can get from this pointer?" -- if, from your debugger, you see a widget with a certain object ID ("pointer"), you might be able to find it in the Hierarchy View. Otherwise, I have no idea what you would use it for. – CommonsWare Dec 16 '12 at 16:02