虽然我是新手, 需要熟悉android各种属性, 但是android也太繁杂了吧,比如xml:
一大堆的android前缀, 要不是多亏了IDEA简直累到死。。。
还有java里的, 比如List<Map<String, String>> child1 = new ArrayList<Map<String, String>>(); 哇卡卡, 前面写了一遍后面又要写一遍。
算了, 吐槽完毕。
所以:请问大, android编程有类似groovy语法之类的偷懒写法(或者说工具?)吗?或者一切可以提高编程效率的方法
![]() | 1 WildCat 2015-05-14 23:05:24 +08:00 via iPhone 传统的静态语言不都这样子? Groovy 欢迎你 |
3 Gonster 2015-05-14 23:21:52 +08:00 jdk的话 1.7 以后 new 后面模板可以不用再写一遍了。。。Android就不清楚了 |
![]() | 4 scarlex 2015-05-14 23:39:50 +08:00 不知道楼主有没写过 web 前端,写过的话再写 android 界面时感觉应该差不多吧。 |
![]() | 5 herozem OP |
![]() | 6 reeco 2015-05-15 00:06:02 +08:00 via iPhone 用好idea |
![]() | 8 aaronmix 2015-05-15 00:43:01 +08:00 kotlin |
![]() | 9 GhostFlying 2015-05-15 00:55:47 +08:00 via Android Idea 已经简单很多了。。想想以前 Eclipse 的日子,不堪回首 |
![]() | 10 zhouquanbest 2015-05-15 01:29:37 +08:00 via Android lambda+rxjava |
![]() | 11 silvernoo 2015-05-15 04:41:36 +08:00 scala |
![]() | 12 mthli 2015-05-15 05:59:26 +08:00 via Android ![]() |
![]() | 13 puncsky 2015-05-15 08:19:36 +08:00 Java 7 开始有 diamond operator List<Map<String, String>> child1 = new ArrayList<Map<String, String>>(); 就变成了 List<Map<String, String>> child1 = new ArrayList<>(); 稍微好一点儿。。 |
![]() | 14 herozem OP @GhostFlying eclipse用的我想哭 @puncsky 嗯, 只能说好了一点点 @mthli 谢谢, 干货 @silvernoo 表示没学过scala, 就算scala写起来应该也不轻松吧(猜 @aaronmix 又是jetbrains ->_-> |
![]() | 15 learnshare 2015-05-15 09:38:13 +08:00 IDE 的代码片段不是用来摆设的 |
![]() | 16 finian 2015-05-15 09:40:40 +08:00 |
![]() | 17 zhea55 2015-05-15 09:52:10 +08:00 verticalLayout { val name = editText() button("Say Hello") { onClick { toast("Hello, ${name.text}!") } } } 看起来很舒服,不过这个东西效率怎样,还不清楚。。 https://github.com/JetBrains/anko |
![]() | 18 herozem OP |
![]() | 19 jaminzzhang 2015-05-15 14:52:06 +08:00 呃,为何不用Android Studio?也是IntelliJ,现在已支持SDK7。写了iOS再写Android,觉得真不算什么。哦,除了NullPointerException |
![]() | 20 iv2ex 2015-05-15 17:24:02 +08:00 Android Studio的提示很好用 不需要你写完整的字段名 写一个字段名中间几个字母都可以 |
21 allan1st 2015-05-15 17:29:45 +08:00 ![]() 我的偷懒方法汇总: * ButterKnife 做 View Injection, OnClick 等 * RxJava 做 Async,配合 leakcanary 检查内存泄露 * Retro-lambda 用 JAVA 8 的 lambda * Stetho debug 网络请求 * 这个比较 Dirty: Realm 在主线程上 query * 终极偷懒项:最低版本设置到 19 或者 21 其实以上第2点第5点坑比较多。。 |
![]() | 22 herozem OP |
23 Gem 2015-05-15 19:26:12 +08:00 写着虽然麻烦,但是好处是每一步都很清楚,也挺好的。 |
![]() | 24 StevenTong 2015-05-15 23:22:35 +08:00 @allan1st 多谢分享 mark 下次一个一个看 |
25 Jabin 2015-05-16 21:41:56 +08:00 强烈推荐AndroidAnnotations 这个框架 |
![]() | 26 Lonely 2015-05-16 23:09:10 +08:00 那你就不要学了,省的自找麻烦 |
![]() | 27 zhanglp888 2015-05-20 10:32:36 +08:00 @Jabin 是不是跟roboguice一样?能给大概介绍一下吗? |
![]() | 28 zhanglp888 2015-05-20 17:05:41 +08:00 @Jabin 自己仔细看了AndroidAnnotations ,真心爱上了它,感谢~~~~ |
![]() | 30 qw7692336 2015-07-12 00:42:52 +08:00 @puncsky 不是可以直接 List<Map<String, String>> child1 = new ArrayList(); 吗?后面的<>都不用了。 @zhanglp888 不要用roboguice,这个东西已经被Google点名批评了,详见 http://developer.android.com/intl/zh-cn/training/articles/memory.html#DependencyInjection 你可以用androidannotations https://github.com/excilys/androidannotations 或者butterknife https://github.com/JakeWharton/butterknife 实现一些方便操作。 https://github.com/evant/gradle-retrolambda 可以让你在Android当中使用lambda表达式。 配合RxAndrod或者RxJava https://github.com/ReactiveX/RxAndroid https://github.com/ReactiveX/RxJava 可以让你的代码变得优雅。 @zhouquanbest @allan1st 为什么不用专用的RxAndroid而用RxJava呢? |