PhatHV
PhatHV

Reputation: 8141

How can I find the XML files from R.id or R.layout in Android?

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

Answers (5)

Pravin Singh
Pravin Singh

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

CSharp
CSharp

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.

  1. Press and hold Ctrl key on keyboard
  2. Get mouse courser on R.layout.XXX
  3. You will get option "Open Declaration". Click on that
  4. And finally you are at layout class of R.java file

Upvotes: 0

Kumar Vivek Mitra
Kumar Vivek Mitra

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

deepa
deepa

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

EGHDK
EGHDK

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.ids 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

Related Questions