Reputation: 8141
I use Eclipse to study some open source projects on Android. I keep seeing R.id.xxx or R.layout.xxx in the Java source code. And I see that they are built from XML files in the /res
folder.
But the problem is that there are hundreds of XML files that can contain the ID that I want to see. Is there any method to see this reference rather than look through every XML file manually?
Thanks in advance.
Upvotes: 5
Views: 5408
Reputation: 19
(1)just hold the ctrl key and move the mouse over the R.id.xxx . Eclipse will show up the option as
open Declaration
open Declaration in Layout/abc.xml
(2) By clicking open Declaration in layout/abc.xml it will leads to the layout file.. if you choose open Declaration, it will goes to declartion part in R.java
hope it will helpful to you.
Upvotes: 0
Reputation: 1583
R.java file in gen folder contains declaration of all layouts(XML file) in "layout" class. You can reach there by following these steps.
Upvotes: 0
Reputation: 33544
Try this...
1. Open the R.java
file,
2. Hold the ctrl button on your keyboard
3. And place your mouse pointer on integer constant whose xml you want to trace.
4. Then select the option "Open declaration in the layout layout_name"
Upvotes: 2
Reputation: 2494
just hold the ctrl key and place the mouse over the R.id.xxx or R.layout.xxxxx. Eclipse will show the option as
open Declaration
open Declaration in Layout/xxxx.xml
By clicking open Declaration in layout/xxx.xml it will leads to the layout file.. if you choose open Declaration, it will goes to declartion part in R.java
i hope it will helpful to you..
Upvotes: 14
Reputation: 18130
R.layout
is the actual layout file
R.id
is a view that is inside the layout.
The only way that a view can be called is if the layout is first inflated.
So my project has to say R.layout
first, and then R.id
s from inside that layout can be used.
The answer to this question might help you: What is the correct term when calling a widget from xml in Android?
It basically explains that the layout file has to be "opened" first before all of the views (buttons, editText, TextViews, etc) inside can be used.
Holding ctrl while clicking will point you where it came from.
Upvotes: 3