Android Studio “Open Declaration” like eclipse

2019-02-05 14:16发布

Is there a function like the "open declaration" in eclipse, that we can use in the new Android Studio?

Just like F3 button.

6条回答
beautiful°
2楼-- · 2019-02-05 14:43

In IntelliJ-IDEA it's Right-Click => Go To => Declaration. As others noted, Android Studio is based on IntelliJ-IDEA and in most of the cases, the experience would be the same.

查看更多
祖国的老花朵
3楼-- · 2019-02-05 14:43

You can click middle mouse button and android studio open declaration or all usage locations of method/variable;

查看更多
家丑人穷心不美
4楼-- · 2019-02-05 14:47
  1. CTRL+B or

  2. Right click, Go to -> Declaration

  3. For Mac: CMD+B

查看更多
beautiful°
5楼-- · 2019-02-05 15:00

^B on the variable.

There is, but it doesn't work sometimes (unlike Eclispe where it always works). Build project. Searches don't work when using Find Usages nor Go to Implementation etc. Free text searches do work. seems to be a disconnect in how AS loads the gradle projects.

The good news is if you create a brand new project with all the defaults then these things work. The project we have was ported from Eclipse to Android Studio by a mobile consultancy based in Austin; so, looks like the porting process is not clean.

In conclusion, the project in which these did not work was fixed by using Import, by using Java 7 (had to fix class path, delete Oracle symlink, etc), and by installing a git client and setting it up to run from the command line. After that, the project not only can be imported but features such as Go To->Declaration started working. And the "NullException" messages which occurred often in Android Studio went away.

查看更多
对你真心纯属浪费
6楼-- · 2019-02-05 15:02

Here are more details to help you avoid asking the same question for all the other commands:

Press Ctrl + Shift + A, and search for the command you're looking for ("declaration") for example. This finds the command "Declaration - Goto by Reference action - Ctrl + B".

So you just need to put your cursor on the method you want to go to, and press Ctrl + B? You can also Ctrl + Click to achieve the same goal.

The most useful keyboard shortcuts are described in the Help - Tip of the day dialog box. Read them all.

查看更多
做自己的国王
7楼-- · 2019-02-05 15:04

In Preferences, I added the shortcut to Navigate->Declaration in Keymap:

Android Studio/IntelliJ Keymap screen -> add a shortcut for Declaration

The cmd+button1 click was added with right click, "add mouse shortcut".

It is interesting, that to make it 'fully' eclipse like, you may want to make the Javadocs appear on hover. For that you must set "Show quick doc on mouse move" up in the Editor->Other section.

Setting up Show quick doc on mouse move in Editor->Other section

查看更多
登录 后发表回答