Muz
Muz

Reputation: 5980

Shortcut to open Android XML layout in Eclipse

For example, if I had something like

setContentView(R.layout.activity_main);

Would there be a shortcut to open activity_main.xml? If not, is there a way to create one?

Upvotes: 3

Views: 3543

Answers (4)

j2emanue
j2emanue

Reputation: 62549

if you have the class file opened instead of the java file it probably wont work. But in the java file press control on windows or command on mac and hover over the element for options to navigate.

Upvotes: 0

BBdev
BBdev

Reputation: 4942

Actually its an id. When you create an XML file in android automatically that file has given an id by Android and you can find it into gen folder and the class name is R.java. So if you want to see that file you have to open res folder -> layout folder -> there you can see that xml file.

But you can do it as @joe or @Spk has suggested you. And Spk's solution is far better. So cheers.

Upvotes: 0

Praveenkumar
Praveenkumar

Reputation: 24496

Its there. Just hold Ctrl and move the cursor to the word activity_main which is the line setContentView(R.layout.activity_main); then, it will be give two option that one is for opening xml layout and another one is opening the declaration in R.java file. This is the shortcut to open the XML layout easily.

Cheers!

Upvotes: 13

Joe
Joe

Reputation: 14059

This is not exactly a shortcut, but you can highlight the activity_main part on that setContentView(R.layout.activity_main); line and then press Ctrl+Shift+R.

The Open Resource dialog that shows up should have activity_main.xml (along with other files with activity_main in their names) at the top of the list. Just press Enter to open the one you want.

Upvotes: 5

Related Questions