xml 一些适用于Android Studio的实时模板。在我的Mac上,这个文件位于`〜/ Library / Preferences / AndroidStudioPreview1.3 / tem
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了xml 一些适用于Android Studio的实时模板。在我的Mac上,这个文件位于`〜/ Library / Preferences / AndroidStudioPreview1.3 / tem相关的知识,希望对你有一定的参考价值。
<templateSet group="android">
<template name="focvb" value="@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_$END$, container, false); ButterKnife.inject(this, view); return view; } " description="Fragment onCreateView with ButterKnife" toReformat="true" toShortenFQNames="true">
<context>
<option name="JAVA_CODE" value="false" />
<option name="JAVA_STATEMENT" value="false" />
<option name="JAVA_EXPRESSION" value="true" />
<option name="JAVA_DECLARATION" value="true" />
<option name="JAVA_COMMENT" value="false" />
<option name="JAVA_STRING" value="false" />
<option name="COMPLETION" value="false" />
</context>
</template>
<template name="fni" value="public static $CLASS_NAME$ newInstance() { return new $CLASS_NAME$(); } " description="Fragment newInstance" toReformat="false" toShortenFQNames="true">
<variable name="CLASS_NAME" expression="className" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template name="fnia" value="private static final String $ARG_PARAM$ = "$CLASS_NAME$.$ARG_PARAM$"; private $ARG_CLASS_DITTO$ m$INST_VAR$; public static $CLASS_NAME$ newInstance($ARG_CLASS$ $ARG_VAR$) { $CLASS_NAME$ fragment = new $CLASS_NAME$(); Bundle args = new Bundle(); args.put$ARG_CLASS$($ARG_PARAM$, $ARG_VAR$); fragment.setArguments(args); return fragment; } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); m$INST_VAR$ = getArguments().get$ARG_CLASS$($ARG_PARAM$); } " description="Fragment newInstance with arguments" toReformat="true" toShortenFQNames="true">
<variable name="ARG_CLASS" expression="typeOfVariable(VAR)" defaultValue="" alwaysStopAt="true" />
<variable name="ARG_VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<variable name="ARG_CLASS_DITTO" expression="ARG_CLASS" defaultValue="" alwaysStopAt="false" />
<variable name="ARG_PARAM" expression="capitalizeAndUnderscore(ARG_VAR)" defaultValue="" alwaysStopAt="false" />
<variable name="CLASS_NAME" expression="className" defaultValue="" alwaysStopAt="false" />
<variable name="INST_VAR" expression="capitalize(ARG_VAR)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template name="@sn" value="@SerializedName("$VAR$") private $TYPE$ m$INSTVAR$;" description="@SerializedName inst var" toReformat="false" toShortenFQNames="true">
<variable name="VAR" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="TYPE" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="INSTVAR" expression="capitalize(VAR)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template name="ani" value="public static Intent newIntent(Context context) { return new Intent(context, $CLASS_NAME$.class); } " description="Activity newIntent" toReformat="false" toShortenFQNames="true">
<variable name="CLASS_NAME" expression="className()" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template name="ania" value="private static final String $EXTRA_PARAM$ = "$CLASS_NAME$.$EXTRA_PARAM$"; public static Intent newIntent(Context context, $EXTRA_CLASS$ $EXTRA_VAR$) { Intent intent = new Intent(context, $CLASS_NAME$.class); intent.putExtra($EXTRA_PARAM$, $EXTRA_VAR$);$END$ return intent; } @Override protected Fragment getFragment() { $EXTRA_CLASS$ $EXTRA_VAR$ = getIntent().get$EXTRA_CLASS$Extra($EXTRA_PARAM$); return $FRAGMENT_CLASS$.newInstance($EXTRA_VAR$); } " description="Activity newIntent with arguments" toReformat="false" toShortenFQNames="true">
<variable name="EXTRA_CLASS" expression="typeOfVariable(VAR)" defaultValue="" alwaysStopAt="true" />
<variable name="EXTRA_VAR" expression="suggestVariableName()" defaultValue="" alwaysStopAt="true" />
<variable name="CLASS_NAME" expression="className" defaultValue="" alwaysStopAt="false" />
<variable name="EXTRA_PARAM" expression="capitalizeAndUnderscore(EXTRA_VAR)" defaultValue="" alwaysStopAt="false" />
<variable name="FRAGMENT_CLASS" expression="groovyScript("_1.replaceAll('Activity','Fragment')", CLASS_NAME)" defaultValue="" alwaysStopAt="false" />
<context>
<option name="JAVA_DECLARATION" value="true" />
</context>
</template>
<template name="toast" value="Toast.makeText($context$, "$text$", Toast.LENGTH_SHORT).show();" description="Toast in fragment or activity" toReformat="false" toShortenFQNames="true">
<variable name="context" expression="groovyScript("_1.endsWith('Activity') ? _1+'.this' : 'getActivity()'", className())" defaultValue="" alwaysStopAt="false" />
<variable name="text" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="JAVA_STATEMENT" value="true" />
</context>
</template>
</templateSet>
以上是关于xml 一些适用于Android Studio的实时模板。在我的Mac上,这个文件位于`〜/ Library / Preferences / AndroidStudioPreview1.3 / tem的主要内容,如果未能解决你的问题,请参考以下文章
在哪里可以找到适用于 Android Studio 3.3 的未弃用地理围栏示例代码?
VSCode 中的 Flutter beta 热重载适用于 Web,但不适用于 iOS 和 Android(适用于 Android Studio)
哪些 Java SE 版本适用于 android studio 3.1?
适用于 Android Studio 的 Team Foundation 插件