I'm trying to create a live template for Fragment's onCreateView()
. This is my template now:
After using it, R
wants to be manually imported.
How can I import application's R
by default? Or can I somehow get the project package name with a groovy script and write it before R
like $PACKAGE_NAME$.R.layout.$LAYOUT_NAME$
to make it work?
Choose File | Manage IDE Settings | Import Settings from the menu. Specify the path to the archive with the exported live template configuration. In the Import Settings dialog, select the Live templates checkbox and click OK.
Go to File -> Export Settings , choose only Live templates , and export it to a file. Then you can use File -> Import Settings and provide this file to import live templates.
Use live templates to insert common constructs into your code, such as loops, conditions, various declarations, or print statements. To expand a code snippet, type the corresponding template abbreviation and press Tab . Keep pressing Tab to jump from one variable in the template to the next one.
Enabling the "Add unambiguous imports on the fly" in File -> Settings -> Editor -> General -> Auto Import -> Java might solve your issue since it will automatically import the R class on the fly, and the need to manually import it will disappear.
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