Shortcut to open Android XML layout in Eclipse

我怕爱的太早我们不能终老 提交于 2019-12-07 16:12:14

问题


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?


回答1:


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!




回答2:


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.




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/12594145/shortcut-to-open-android-xml-layout-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!