Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the shortcut for find a usage of XML file in android studio?

As you know there is many useful shortcuts that improve you coding speed.

One of them is find usage of Class or Method that works with Alt+F7 or Ctrl+b. they works on methods and class names but I wonder how I can find a Usage of XML file like Layout Without Search in project and use Find Usage.

Because the name of XML file is not in the file Like classes and I Always search it's name in whole project. I googled but could not find any answer.

like image 780
Mahdi Avatar asked Dec 25 '16 07:12

Mahdi


People also ask

Where is activity main XML in Android Studio?

In the Project window, open app > res > layout > activity_main. xml.

What is the uses of Android XML file?

Android applications use XML to create layout files. Unlike HTML, XML is case-sensitive, requires each tag be closed, and preserves whitespace. View: An object from Android's built-in View class. It represents a rectangular area of the screen.


2 Answers

All keys are given for windows

CTRL + F for find keywords in a single file

Can do it like this Find usage of an XML| ALT + F7 after you select the XML layout

enter image description here

There is another way(not sure you gonna like it) .. Try to delete a xml and it will not be deleted at the first time.It will show you all the usages of it ask you to confirm you deletion. You can see all the usages at the terminal,so that way you can find them all.

enter image description here

click on view usages button it will show them all

For any short-key File -> Settings -> Keymap -> (you can even Choose Eclipse/Visual Studio short key types in android studio)

Here are some default short keys for windows

Format code | CTRL + ALT + L

Add unimplemented methods | CTRL + I

Show logcat | ALT + 6

Build | CTRL + F9

Build and Run | CTRL + F10

Find | CTRL + F

Find in project| CTRL+SHIFT + F

Find and replace | CTRL + R

Find and replace in project | CTRL + SHIFT + R

Override methods | CTRL + O

Show project | ALT + 1

Hide project - logcat | SHIFT + ESC

Collapse all | CTRL + SHIFT + NumPad +

View Debug Points | CTRL + SHIFT + F8

Expand all | CTRL + SHIFT + NumPad -

Open Settings | ALT + s

Select Target (open current file in Project view) | ALT + F1ENTER

Search Everywhere | SHIFTSHIFT (Double shift)

Code | Surround With | CTRLALT + T

Create method form selected code | ALT + CTRL

like image 108
Charuක Avatar answered Oct 08 '22 20:10

Charuක


My personal preference is ctrl+shift+f. It will display a popup dialog in which you can type the thing that you are searching and it will look in your entire project folder.

Alternately there is already a Find Usage feature in xml when you right click it. And it does shows the file that uses it.

enter image description here

In my example I did find the use of my analytics_debug.xml then a mini console below will show indicating which file uses it. Selecting the file in usage console redirects you to the exact line of code in which the XML is called.

I reproduce this usecase in Ubuntu 16.04, A.S. version 2.1.1.

like image 4
Enzokie Avatar answered Oct 08 '22 21:10

Enzokie