luisforque luisforque - 25 days ago 13
Android Question

How to create custom keyboard shortcut in Android Studio

I was working on Eclipse before, and there I created a template to quickly add logs inside Android.
So I started typing something, and then the IDE auto-completed to:

android.util.Log.d("SOME_TAG", "&{cursor}");

(one example, there were a few others)

Is there a similar feature in Android Studio?
I've seen the keymap settings, but could not find a way to create a custom element.

Thank you in advance.

Answer

Found this article that explains how to do so. The term I was looking for is Live Template https://medium.com/google-developers/writing-more-code-by-writing-less-code-with-android-studio-live-templates-244f648d17c7#.p3ech1tko

Go to File > Settings > Editor > Live Templates. Click the Android group, and press the plus button to add a new Live Template. You’ll want to choose an abbreviation to use the template, a description to remember what it does, and of course the code you’d like it to insert

Comments