AS Live Templates
来源:互联网 发布:淘宝无名体育怎么样 编辑:程序博客网 时间:2024/06/05 21:51
在编辑器中使用用Ctrl + J
快捷键可以调出Live Templates,可以自动补全所设置模板的代码,善用它能够在很大程度上减少开发所需时间。
设置位置
- 设置方法:
Live Template 语法
可以为每个Template指定名字和语句(废话),并且指定适用的文件类型和语句块(修改底部的Applicable in … 即可)
在语句中使用$...$
表示待输入的变量(字符串内也可以用),你在每次输入的时候相同的变量会一起改变。(如在语句中含有两个$i$,则你使用模板时改变其中一个的值,另一个也会一起改变)
可以使用Edit Variable 对它进行一部分修改,它可以修改以下部分
$...$
为变量赋特殊值默认值使用时是否跳过编辑在Expression内有很多供使用的非常方便的函数,如className(), methodName()等等。设置Expression后别忘了勾选Skip if defined, 这样在使用的时候光标就不会再停留在这个变量处。
常用Android模板示例
findViewById 以下所有$cast$
变量的expression值均为expectedType()
.
示例:
Bitmap初始化 $resource$
设置defaultValue为"getResources()"
示例:
Log
以下$method_name$
的expression值为 className()
, $method_name$
的expression值为methodName()
。
示例:
For循环
$cursor$
}fiterfor ($i$=$start$; $i$<$end$; $i$++) {
$cursor$
}fiter_with_initfor (int $i$=$start$; $i$<$end$; $i$++) {
$cursor$
}
示例:
常量定义
注意不要把Live Template的名字命名得和常用变量名太像,因为不点击Ctrl+J
时输入模板名字+TAB同样也会调出模板,若和常用的变量如(Bitmap, int, string等)命名相近会造成不必要的麻烦。
现在你可以调用这些模板了,快去定义自己喜欢的各种模板吧!
- AS Live Templates
- Live templates in AS
- 工具篇AS之 live templates
- AS创建简单的live templates
- Live templates(模板)
- Android Studio-live Templates
- AndroidStudio-Live Templates
- Groups of Live Templates
- Sharing Live Templates
- android studio live templates
- ANDROID STUDIO LIVE TEMPLATES
- intellij live Templates 设置
- live templates简单介绍
- live templates语法
- IntelliJ IDEA---Live Templates
- IntelliJ IDEA设置live templates
- Creating and Editing Live Templates
- Android Studio Live Templates 详解
- git学习-本地版本库管理命令
- 三级缓存
- 【Linux】信号通讯编程
- 表达式语法分析——预测分析法
- Web Service快速入门
- AS Live Templates
- Camera中onPreviewFrame()方法的视频方向旋转
- 网站数据数据分析-网站js埋点
- 模拟
- 最短路模板 floyd+dijkstra+spfa
- spring+quartz实现任务调度
- Linux下的管道通信
- 【网站国际化必备】Asp.Net MVC 集成Paypal(贝宝)快速结账 支付接口 ,附源码demo
- MATLAB 中的fix(),floor(),ceil(),以及round()