首页 > 解决方案 > 如何在 ubuntu 的 android studio 中添加新的实时模板

问题描述

我正在使用 ubuntu 20.04,我最近正在研究 android studio 中的实时模板

但我没有找到模板文件夹

我搜索了每一个地方,就像这种自我感觉一样

https://stackoverflow.com/a/44177549

或者这个

https://stackoverflow.com/a/51647302

或者

https://medium.com/gits-apps-insight/tutorial-create-your-own-template-for-android-studio-1aaa9b4cb18

和很多其他网站,没找到

我正在使用安卓工作室 4.1

谢谢你的帮助

标签: androidandroid-studio

解决方案


有一个解决方法。您可以从以前的 android studio 版本导出(或手动创建“设置文件”),而不是在预期目录中复制/粘贴文件。然后你“只是”必须将它作为设置导入。

我的“template_settings.zip”包含:

  • 选项
  • 模板
  • “IntelliJ IDEA 全局设置”文件
  • “安装的.txt”

在“模板”文件夹中,您可以放置​​一个文件“MyAndroidLog.xml”,其中包含:

<templateSet group="MyAndroidLog">
  <template name="loguw" value="LogUtils.w(BuildConfig.DEBUG, LOG_TAG, &quot;$METHOD_NAME$: $content$&quot;);" description="Custom Log.w(TAG, String) with LogUtils" toReformat="true" toShortenFQNames="true">
    <variable name="METHOD_NAME" expression="methodName()" defaultValue="" alwaysStopAt="false" />
    <variable name="content" expression="" defaultValue="" alwaysStopAt="true" />
    <context>
      <option name="JAVA_STATEMENT" value="true" />
    </context>
  </template>
</templateSet>

请告诉我是否不够清楚!


推荐阅读