Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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? I'm using 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.

PS: I'm new to Android studio (started using it about a month ago).

like image 610
Omar BISTAMI Avatar asked Mar 12 '15 01:03

Omar BISTAMI


People also ask

Where is the method in Android Studio?

Method 1. Step 1: In Android Studio 4.0's settings window, go to “Editor” > “General” and check “Show quick documentation on mouse move”.

How do you call a method in Android?

To call a method in Java, you type the method's name, followed by brackets. This code simply prints “Hello world!” to the screen. Therefore, any time we write helloMethod(); in our code, it will show that message to the screen.

What are methods in Android Studio?

A Method provides information about, and access to, a single method on a class or interface. The reflected method may be a class method or an instance method (including an abstract method).


2 Answers

In Android Studio, highlight the method and either right click > Find usages or use the Alt+F7 shortcut.

Edit: Ctrl+left click on a method is useful for finding where that method was initially declared

like image 70
John P. Avatar answered Sep 20 '22 21:09

John P.


For Ubuntu users:

For me Alt+F7 has not worked, so I've solved the conflict by going to the

Ubuntu System settings-> keyboard -> shortcuts 

and changing Alt+F7 in there with another combination.

And now it's working ))

like image 35
Andrew Avatar answered Sep 22 '22 21:09

Andrew