包别名或昵称 [英] Package name alias or nickname
问题描述
是否有可能创建一个昵称包名,我可以在XML文件中引用?
Is it possible to create a nickname for a package name, that I can refer in xml file?
我不想写全包名如: com.example.go.deck.today,而不是我可以创建一个别名,并指该别名?
I don't want to write the whole package name e.g. com.example.go.deck.today instead can I create an alias and refer that alias?
我想引用包名的别名或昵称,而不是在Android /布局XML文件中。
I'd like to refer an alias or nick instead of the package name in an android/layout XML file.
推荐答案
安卓本身并不能提供这样的设施。但是你可以用蚂蚁来为你做它。你可以写一个自定义的build.xml文件,自定义目标<目标名称= - code根>
在<$ C做令牌替换$ C>研究类生成。你可以添加规则:
Android by itself does not provide such facility. However you can use the ant to do it for you. You could write a custom build.xml, customizing the target <target name="-code-gen">
to do token replacement before the R
class is generated. You could add the rule :
<replace file="targetFile" token="@PACKAGE_ALIAS@" value="com.example.go.deck.today"/>
这将取代 @PACKAGE_ALIAS @
每次出现在 com.example.go.deck.today
的的TargetFile
。
this would replace every occurrence of @PACKAGE_ALIAS@
by com.example.go.deck.today
in the targetFile
.
我不是一个蚂蚁
专家,但根据以往的经验,我会说,它不会很难写,可以扫描所有文件中的<$ C规则$ C> RES 目录。
I am not an ant
specialist but based on past experience I would say that it would not be hard to write a rule that could scan all file in the res
dir.
这篇关于包别名或昵称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!