Android Studio wizard for Fragments and other templates

﹥>﹥吖頭↗ 提交于 2019-12-05 23:15:38

For future readers!

As CommonsWare mentioned in comments changing the templates may not last longer as Android Studio updates may overwrite them. So you may create your own custom file templates as described in following article.

https://riggaroo.co.za/custom-file-templates-android-studio/

Here you may have to create two file templates

  • One for Fragment class
  • Another for fragment layout file

Another way to go about changing the fragment template is to backup the original files of that you are going modify and modify the existing templates and backup the modified templates in order to restore the modifications after an Android Studio update.

It's important to backup original files before modification, because when updating android studio in future, it will notify you about files being modified, so the update could not be completed. So you have to restore the original version of the modified files, before updating the android studio.

If you need to change Fragment template (Blank fragment template), navigates to

[android-studio-ndredirectory]/plugins/android/lib/templates/other/BlankFragment/root/src/app_package

and modify the source file of your choice. (BlankFragment.kt.ftl or BlankFragment.java.ftl), in order to modify the source file template.

Navigate to

[android-studio directory]/plugins/android/lib/templates/other/BlankFragment/root/res/layout

and modify the fragment_blank.xml.ftl, in order to modify the layout file template.

After doing your modifications, you may backup the BlankFragment directory, so you can restore your changes, after the Android Studio update.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!