魅力程序猿

  • 首页
  • Java
  • Android
  • APP
    • 扑克计分器
    • Video Wallpaper
  • 联系我
  • 关于我
  • 资助
道子
向阳而生
  1. 首页
  2. Android
  3. 正文

Android studio 快速代码模板生成常用的缩写

2016年12月1日 14001点热度 0人点赞 5条评论

为了提高书写代码的速度,我们会使用快捷键Ctrl+D(粘贴当前行或选中的内容到下一行),以前也整理过:Android Studio 默认的快捷键大全解释,这里有必要在说说快速代码模板生成常用的缩写。先看几个gif,后面告诉您在Android studio哪里看所有的和修改的地方,也会附录常用的。

1、快速生成TAG:logt

as_tag

2、快速生成public static final  :psf

as_psf

3、快速生成public static final String :psfs

as_psfs

4、快速生成public static final int :psfi

as_psfi

5、快速生成public static AppManager getInstance() {return mAppManager;}:geti

as_geti

6、快速生成for (int i = 0; i < ; i++) {}:fori

as_fori

这写我们可以在setting-->Live Templates里查看也可以进行编辑:

as_live_templates

附 常用快速代码模板生成的缩写

一.输出打印

(1).serr --->System.err.println("example")

(2).souf --->printf "example"

(3).sout --->println "example"

(4).soutm --->System.out.println("MainActivity.onCreate");//当前类的当前方法名

(5).soutp --->System.out.println("savedInstanceState = [" + savedInstanceState + "]");//这个好,可以打         印出当前方法的所有参数列表及其值

(6).soutv --->System.out.println("params",params);//即 你可以输出打印一个变量值

二.(常规的代码块儿)

Iteractions--->//快速生成代码块儿

(1).fori --->for (int i = 0; i < ; i++) {  }

(2).itar --->for (int i = 0; i < Array.length; i++) { int i1 = Array[i];}//遍历数组

(3).itco --->for (Iterator iterator = collection.iterator(); iterator.hasNext(); ) { }

(4).Object next = iterator.next();}//这个是遍历一个容器变量的,直接让容器返回一个iterator进行遍历

(5).iten --->while (枚举类.hasMoreElements()) { Object nextElement = 枚举类.nextElement(); }//enumeration 是一个枚举类接口来着。遍历枚举内容

(6).iter --->for (int i : FOCUSED_STATE_SET) {...}//遍历选中状态下的set

(7).itit --->while (iterator.hasNext()) { Object next = iterator.next(); }//获取到了迭代器对象后,对迭代器进行遍历操作

(8).itli --->for (int i = 0; i < list.size(); i++) { Object o = list.get(i); }//遍历list对象里面的内容

(9).ritar --->for (int i = Array.length - 1; i >= 0; i--) { int i1 = FOCUSED_STATE_SET[i]; }//倒叙遍历数组

//其他的(综合)

(10).geti --->public static MainActivity getInstance() { return ; }//获取到当前的实例 的代码模板

(11).ifn --->if (某变量 == null) {....}//生成if null代码块儿

(12).inn --->if (某变量 != null) {....}//生成if not null代码块儿

(13).inst --->if ($EXPR$ instanceof $TYPE$) { $TYPE$ $VAR1$ = ($TYPE$)$EXPR$; $END$ }//判断某变量是不是某个类的实例对象

(14).lazy --->if (savedInstanceState == null) { savedInstanceState = new Bundle(); }//执行延迟初始化,就是对象直到用的时候才进行初始化操作

(15).mn --->var1 = Math.min(var2,var3);//得到比较两个变量值小的代码块

(16).mx --->var1 = Math.max(var2,var3);//得到比较两个变量值大的代码块

(17).psvm --->public static void main(String[] args){ 。。。。 }//生成一个main()函数的代码块

(18).toar --->something.toArray(new collection[collection.size()])//这个是生成一个代码块用于把collection的对象存储到一个数组里面去.实用!

2.普通的代码(修饰符部分的)

(1).psf --->public static final

(2).psfi --->public static final int

(3).psfs --->public static final String

(4).St --->String

(5).thr --->throw new

 

 

标签: Android studio快速代码模板生成常用的缩写 Android studio的live templates AS快速代码模板生成常用的缩写
最后更新:2016年12月1日

daozi

这个人很懒,什么都没留下

点赞
< 上一篇
下一篇 >

文章评论

  • Maliyah

    BTWE, inflation is deader than Jimmy Hoffa. Sure, oil blah, blah, blah. Oil is at an unsustainable level. It will come down again. US farmers are boosting acreages, looking at higher prices and even more federal subsidies. Commodities typically have bowo.s..fmllooed by busts. Nature of the beast. Gold? Can't tell you. The bulk of gold is sold in India and China for jewelry. It is going up with middle-class incomes in Chindia. Not related to US monetary policy.

    2016年12月18日
    回复
  • Viney

    Now I feel stpidu. That's cleared it up for me

    2016年12月18日
    回复
  • growtopia hacks

    Great, bing took me stright here. thanks btw for info. Cheers!

    2017年9月26日
    回复
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    取消回复
    搜索
    联系方式

    QQ群:179730949
    QQ群:114559024
    欢迎您加入Android大家庭
    本人QQ:136049925

    赐我一丝安慰
    给我一点鼓励

    COPYRIGHT © 2023 魅力程序猿. ALL RIGHTS RESERVED.

    Theme Kratos Made By Seaton Jiang

    豫ICP备15000477号