I've created a Live Template under the "user" template group. I've set the Abbreviation to "setpref". It is listed on my list of Live Templates, but it is not available when I type "setpref" in a code window. I'm guessing that I've missed something obvious but can't work out what. Any ideas??
To create a Live Template, in Android Studio or IntelliJ open Preferences ‣ Editor ‣ Live Templates. In this window, you can explore some of the existing templates you can use, what their shortcuts are, and edit the shortcuts and generated code. This is also where you can create a new template.
Android Studio (and in consequence, IntelliJ) comes with a feature called Live Templates which allow developers to customize shortcuts or abbreviation that translates to written code. Following the previous example, we have a default shortcut for that, in Java and in Kotlin.
Android Studio provides code templates that follow the Android design and development best practices to get you on the right track to creating beautiful, functional apps. You can use templates to create new app modules, individual activities, or other specific Android project components.
To make the Live Templates appear again, do the following:
1) Open Editor>Live Templates
2) When you find templates with issues, select them and do step 4-6
3) At the bottom, click Change where it says "Applicable in..."
4) In the popup, under Java select statement to make templates like logd, logm, logw etc be available inside methods.
5) Select declaration to make templates like logt available in classes' field declarations.
Done!
Visit this link - https://www.reddit.com/r/androiddev/comments/3n9nis/issues_with_live_templates_in_android_studio_try/?st=j0pjkc4w&sh=e84eb254
Have fun ! :) It works.
Please make sure that you've correctly specified the context for your live template (the set of languages in which it's available).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With