android-studio - 在哪里可以找到 Android Studio“代码和文件模板”中可用的变量列表?
问题描述
自定义 java 代码和文件模板时,我在哪里可以获得可用的变量列表?
例如,在自定义 java 类时,我知道我可以使用 ${USER} 和 ${DATE},我(正确地)猜到了 ${YEAR} 可用......但我想找到所有可用的预定义变量用来。
我查看了 Apache 的通用 VTL 语言文档,但没有找到我要搜索的信息。
解决方案
我找到了清单!在 Android Studio 中,我去了 File | 新 | 编辑文件模板这带来了一个对话框“文件和代码模板”,默认选项卡是“文件”。默认文件类型是 HTML。在描述框中,它有一个很好的长文本来显示它们。用于此的 HTML 在位于 C:\Program Files\Android\Android Studio\lib\java_resources_en.jar 的 java_resources_en.jar 内的 default.html 中
Along with static text, code and comments, you can also use predefined variables (listed below) that will then be expanded like macros into the corresponding values.
It is also possible to specify an arbitrary number of custom variables in the format ${<VARIABLE_NAME>}. In this case, before the new file is created, you will be prompted with a dialog where you can define particular values for all custom variables.
Using the #parse directive, you can include templates from the Includes tab, by specifying the full name of the desired template as a parameter in quotation marks. For example:
#parse("File Header.java")
Predefined variables will take the following values:
${PACKAGE_NAME} name of the package in which the new file is created
${NAME} name of the new file specified by you in the New <TEMPLATE_NAME> dialog
${USER} current user system login name
${DATE} current system date
${TIME} current system time
${YEAR} current year
${MONTH} current month
${MONTH_NAME_SHORT} first 3 letters of the current month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL} full name of the current month. Example: January, February, etc.
${DAY} current day of the month
${DAY_NAME_SHORT} first 3 letters of the current day name. Example: Mon, Tue, etc.
${DAY_NAME_FULL} full name of the current day. Example: Monday, Tuesday, etc.
${HOUR} current hour
${MINUTE} current minute
${PROJECT_NAME} the name of the current project
推荐阅读
- angular - Angular 8 - 路由未发生 - 垫表行
- boost-asio - asio 使用_future 而不是 yield[ec]
- android - 我无法在 Android Studio 中的图像下放置 textview?
- c++ - 错误:从 'const char*' 到 'int' 的无效转换
- reactjs - 如何反应更新特定状态内部状态对象?
- html - 如何在 TypeScript 中转置对象数组?
- ajax - 使用ajax的控制器(ASP.Net MVC)中的输入值为空
- php - php str_getcsv 从数组中删除 null 或 ' ' 值
- delphi - Delphi,在设计时,使用 nil 所有者创建时 ComponentState、ControlState 的状态是什么?
- excel - 如何将我的 VBA 进程转换为在 MAC 中运行?