Live Template: Write less code.

A lazy developer tool.

Shubham Patni
2 min readDec 24, 2018

IDE’s are amazing so their developers. It’s so easy to kick off the development and to focus on what you really need to develop instead to build supportive tool every time.

In this session we are going to see Android Studio support for Live Teamplate. Just another IDE feature supported by IntelliJ.

Live templates are frequently-used or custom code constructs that give you some very useful Smart Shortcut to write the code statement in simple & quickest :)

Before going to in depth let’s try some templates. Steps are simple, open IDE and create a .java class; and there type psfi and hit enter. Wolla, it write public static final int directly. Try some more like psfs, logo, logd.

You can checkout list of predefined template and then we will see how one can create their own custom template.
Here you go: Android Studio -> Preferences -> Live Templates.

Build Custom Templates

It’s easy with following steps.

  1. Open Android Studio -> Preferences -> Live Templates . It display list of predefined live templates by category.
  2. Click on + icon right side of window. To create own new group click on Template group, and say you give it a name Droid LT.
  3. Now click on Group (i.e. Droid LT) and click + icon again & select Live Template option.
  4. It’s time to add your magic. Give a suitable abbreviation & then add your template text below to that. Here in example we have added EditText with support of AndroidX lib component.
  5. One more steps, don’t forget to add support category; click on “Define” will see list of category. And apply and OK and you are done.🤗

Open Xml layout file and type editx and hit enter & it’ll add EditText template for you. Cool noo !!

Like this, you can build complex layout like login, signup, list layout, runtime implementation like Adapter we usually called File Template.

We used to use of number of such templates and it’s chance to build your own. Let’s build and share. #HappyCoding 👩‍💻🤗

--

--

Shubham Patni

#HumanBeing #Programmer #Android #AWS #ML #MedicalDeviceSoftware