[英]How can i find where a method or a variable is used in Android Studio (shortcut)
I know how to find the source by using ctrl + left click on a method, for example, but what if I want to find where this method is used?例如,我知道如何通过使用ctrl + 左键单击某个方法来查找源,但是如果我想查找使用此方法的位置怎么办? I'm using Windows 7.
我正在使用 Windows 7。
Let's suppose I have the following method:假设我有以下方法:
class A {
public int sum(int a, int b) {
return a+b;
}
}
and I am using this method in我正在使用这种方法
class B {
...
a.sum(c, d);
...
}
and I want to find where I used sum
while I was in class A
.我想找到我在
A
班时使用sum
地方。
PS: I'm new to Android studio (started using it about a month ago). PS:我是 Android Studio 的新手(大约一个月前开始使用它)。
In Android Studio, highlight the method and either right click > Find usages or use the Alt + F7 shortcut.在 Android Studio 中,突出显示该方法,然后右键单击 > 查找用法或使用Alt + F7快捷方式。
Edit: Ctrl + left click on a method is useful for finding where that method was initially declared编辑: Ctrl +左键单击某个方法对于查找该方法最初声明的位置很有用
For Ubuntu users:对于 Ubuntu 用户:
For me Alt + F7 has not worked, so I've solved the conflict by going to the对我来说Alt + F7没有用,所以我通过转到
Ubuntu System settings-> keyboard -> shortcuts
and changing Alt + F7 in there with another combination.并使用另一种组合更改Alt + F7 。
And now it's working ))现在它正在工作))
只需单击方法或变量,任何用法都会突出显示,在代码右侧的滚动条上,您会看到灰色条出现,这些是当前突出显示(或单击)的变量或方法在您的代码中的用法代码。
To find all uses of a variable or method in Android Studio you can use要在 Android Studio 中查找变量或方法的所有用途,您可以使用
Here are different key shortcuts for displaying method or variable usage.以下是用于显示方法或变量用法的不同快捷键。 The keymaps with F14 in them were added by me;
里面有F14的keymap是我自己加的; the others are default.
其他都是默认的。 For Windows (and Linux?), replace the ⌘ key with Ctrl (I think).
对于 Windows(和 Linux?),将⌘键替换为Ctrl (我认为)。 Find Usages shows them in a dedicated window in Android Studio (the solution in other answers), while Show Usages puts them in a popup (second image below).
Find Usages 将它们显示在 Android Studio 的专用窗口中(其他答案中的解决方案),而 Show Usages 将它们放在弹出窗口中(下图第二张)。
使用 [Ctrl+b] 或 [Ctrl+Alt+b] 导航到方法的原点或变量的清除和实现
Ubuntu is Ctrl+Alt+7
or Ctrl+b
to show the usage of the class. Ubuntu 是
Ctrl+Alt+7
或Ctrl+b
来显示类的用法。 Ctrl+Alt+F7
is not work. Ctrl+Alt+F7
不起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.