AlexAndro
AlexAndro

Reputation: 1928

How to find where I have declared an "@+id/widget" in XML, starting from R.java?

It happens to me to declare widgets by id in XML files (@+id/widget) and to forget in which XML file I have declared, especially when I have a lots of ids and XML files.

Usually I look for them in R.java where they are nice sorted. But I see nowhere the XML file where they are declared. And I have to browse through all XML files which is annoying.

On right_click-> Open Declaration, R.java is opened, at line:

public static final int widget=0x7f090012; maybe this is the normal behaviour but

I wander if is there a way to get from R.java in the XML file where I have declared the widget, like @+id/widget. Or any other quick access method.

I'm using Eclipse, downloaded with "ADT Bundle".

Upvotes: 0

Views: 544

Answers (7)

Jelil Adesina
Jelil Adesina

Reputation: 287

If you press the ctrl button while placing your cursor on the variable names in the R.java, the link to its corresponding xml file will pop up.

Upvotes: 0

Mehul Joisar
Mehul Joisar

Reputation: 15358

You can also get it from the root directory of all the xml files.

STEP 1: Select your layout folder,

enter image description here

STEP 2: Press Control+H, enter image description here

->enter your search keyword i.e. widget // I have used btnDone

->select the scope

->Click on Search button

STEP 3: Look at the accurate results provided in Search tab, enter image description here

I hope it will be helpful !

Upvotes: 1

She Smile GM
She Smile GM

Reputation: 1332

in Eclipse environment

  • click your android project then Ctrl+H
  • click File Search tab
  • type-->widget
  • choose file name patter in the next text field---> *.xml
  • in Scope section, select Workspace, hit Search button.

Upvotes: 1

KDeogharkar
KDeogharkar

Reputation: 10959

while pressing window/command key if you in macos or ctrl if you in windows move your mouse pointer to @+id/widget and you will see different declaration places like :
/enter image description here
you will see then different xml file where you declare that id. just click any of .xml file then

Upvotes: 4

Quentin G.
Quentin G.

Reputation: 1003

To avoid this kind of problem it's better to name your ids in correlation with the xml file name. For example if you have home.xml start your ids with "home_". You shouldn't need to go through R.java. You can do a file search with eclipse to find "@+id/widget".

Upvotes: 0

Mohammad Ersan
Mohammad Ersan

Reputation: 12444

Using Eclipse IDE, Hold CTRL key and point the mouse the id in your java code, then a list shown, -Open Deceleration in *, example:

View v = findViewById(R.id.textView1);

hold ctrl and point the mouse on textView1.

if you are using MAC then use Command instead Ctrl

Upvotes: 0

Calvin
Calvin

Reputation: 3312

In Eclipse, press Ctrl+H and type "@+id/widget". The search result will tell you all the files that contains "@+id/widget"....

Upvotes: 1

Related Questions