Templates 在android studio中添加动态参数
我正在使用freemarker创建一个模板。我想在运行时添加几个参数。如何做到这一点。以下是示例模板代码:Templates 在android studio中添加动态参数,templates,plugins,android-studio,freemarker,Templates,Plugins,Android Studio,Freemarker,我正在使用freemarker创建一个模板。我想在运行时添加几个参数。如何做到这一点。以下是示例模板代码: <?xml version="1.0"?> <template minApi="7" minBuildApi="8"> <category /> <dependency name="android-support-v4" revision="8" /> <parameter id="packageName
<?xml version="1.0"?>
<template
minApi="7"
minBuildApi="8">
<category />
<dependency name="android-support-v4" revision="8" />
<parameter
id="packageName"
name="Package name"
type="string"
constraints="package"
default="com.mycompany.myapp" />
...
...
...
<!-- 128x128 thumbnails relative to template.xml -->
<thumbs>
<!-- default thumbnail is required -->
<thumb>thumb_file.png</thumb>
</thumbs>
<globals file="globals.xml.ftl" />
<execute file="recipe.xml.ftl" />
...
...
...
thumb_file.png
我想在单击模板中的按钮时生成一个参数。有可能吗?是否有合适的文档可用。您可以使用
可见性属性。例如,在以下情况下:
<parameter
id="includeLayout"
name="Create layout XML?"
type="boolean"
default="true"
help="Generate a layout XML" />
<parameter
id="layoutName"
name="Layout Name"
type="string"
constraints="layout|nonempty|unique"
default="fragment_default"
visibility="includeLayout"
suggest="fragment_${camelCaseToUnderscore(className)}"
help="The name of the fragment layout to create" />
visibility=“includeLayout”
意味着只有当includeLayout
被选中为true时,该字段才可见。您可以使用visibility
属性。例如,在以下情况下:
<parameter
id="includeLayout"
name="Create layout XML?"
type="boolean"
default="true"
help="Generate a layout XML" />
<parameter
id="layoutName"
name="Layout Name"
type="string"
constraints="layout|nonempty|unique"
default="fragment_default"
visibility="includeLayout"
suggest="fragment_${camelCaseToUnderscore(className)}"
help="The name of the fragment layout to create" />
visibility=“includeLayout”
意味着只有当includeLayout
被选中为true时,该字段才可见感谢@gnardini的回复。但我想根据用户输入添加新字段。谢谢@gnardini的回复。但我想根据用户输入添加新字段。