From the course: Android Studio Essential Training 2020
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Create and use live templates
From the course: Android Studio Essential Training 2020
Create and use live templates
- [Instructor] In Android Studio, a live template is a combination of an abbreviation, and a bit of template code. When you type the abbreviation and press the tab key, it expands to the template. And then lets you fill in information. Here's some examples of live templates that Android Studio 4 already includes for use with Kotlin. If I type the word toast in lowercase, I see toast pop up in the auto-complete list. If I press tab, that expands, to a call to the makeText function of the Toast class. The cursor lands in the first parameter location, and I can type in something, that will be the context. Then when I press enter or return, the cursor will jump to the next place where I need to enter something. Here, I'm between a couple of double quotes, so I can type any string. After I've filled in all those variable values, the cursor will jump to the end of the template. Here's another example. Let's say I waned to trace some information and display a message…
Contents
-
-
-
-
-
-
-
-
(Locked)
Create new Kotlin and Java code files3m
-
(Locked)
Edit code files in the editor window3m 15s
-
(Locked)
Useful code editing shortcuts4m 49s
-
(Locked)
Refactor and inspect code3m 6s
-
(Locked)
Create and use live templates3m 32s
-
Edit layouts with design and text mode3m 36s
-
(Locked)
Add MotionLayout to an XML layout file2m 2s
-
(Locked)
Animate views in the Motion Editor4m 56s
-
(Locked)
Challenge: Extract code to a new class1m 8s
-
(Locked)
Solution: Extract code to a new class2m 12s
-
(Locked)
-
-
-
-