好的插件能加快项目的开发速度,尤其是一些针对重复性的代码的插件,所以在这里向大家推荐2款不错的插件,如果以后发现新的好的插件,还会继续推荐,同时欢迎大家推荐
GsonFormat

GsonFormat是一款将json直接转换成JavaBean的工具,这样就避免了我们经常需要照着接口文档来写实体类bean,而且还要看着不要写错,同时也节省了大量的时间

第一步:安装

首先点击设置按钮,通过File菜单进入设置也行

然后选择Plugins 

在上面输入框输入GsonFormat或者gson都行  然后点击browse

选择GsonFormat 点击右边的install,然后就等待安装完成并且重启

第二步:使用

首先我们创建一个类(类名不限),然后在类中按下alt+insert 或者右键点击generate也行,选择选择gsonformat,或者完全可以直接按快捷键alt+s会弹出一个框,吧得到的json复制进输入框点击ok

在点击ok就能直接生成bean了

我是用以下json生成的bean

  1. {
  2. "people":[
  3. {"firstName":"Brett","lastName":"McLaughlin","email":"aaaa"},
  4. {"firstName":"Jason","lastName":"Hunter","email":"bbbb"},
  5. {"firstName":"Elliotte","lastName":"Harold","email":"cccc"}
  6. ]
  7. }

JavaBean

  1. package wang.raye.viewdemo.bean;
  2. import java.util.List;
  3. /**
  4. * Created by Raye on 2016/3/28.
  5. */
  6. public class JsonBean {
  7. /**
  8. * firstName : Brett
  9. * lastName : McLaughlin
  10. * email : aaaa
  11. */
  12. private List<PeopleBean> people;
  13. public List<PeopleBean> getPeople() {
  14. return people;
  15. }
  16. public void setPeople(List<PeopleBean> people) {
  17. this.people = people;
  18. }
  19. public static class PeopleBean {
  20. private String firstName;
  21. private String lastName;
  22. private String email;
  23. public String getFirstName() {
  24. return firstName;
  25. }
  26. public void setFirstName(String firstName) {
  27. this.firstName = firstName;
  28. }
  29. public String getLastName() {
  30. return lastName;
  31. }
  32. public void setLastName(String lastName) {
  33. this.lastName = lastName;
  34. }
  35. public String getEmail() {
  36. return email;
  37. }
  38. public void setEmail(String email) {
  39. this.email = email;
  40. }
  41. }
  42. }

怎么样很方便吧,下面介绍PreIOC

PreIOC

PreIOC是针对PreIOC框架的一个插件,PreIOC是一个预编译的注解框架,关于详细的PreIOC相关资料可以去主页查看git.oschina或者github

第一步:安装

同前面gsonFormat的安装差不多,不过搜索的时候需要搜索PreIOC,目前关于PreIOC的结果只有一个,所以可以选择安装

第二步:使用

使用PreIOC有个前提,就是项目必须要使用了PreIOC 1.0.6版本,之前的老版本不予支持,同时为了避免Bug建议切换到新版,使用PreIOC 1.0.6

  1. compile 'wang.raye.preioc:preioccore:1.0.6'

同时好一个布局,在需要在Activity、Fragment、Adapter需要使用的控件设置好id,然后在布局名称处右键点击generate 

选择Generate PreIOC Injections

在弹出的框中判断是否有需要修改的属性名称和不要引用的id(去掉勾选),如果需要点击事件则勾选OnClick列的checkbox,如果是创建ViewHolder则选择ViewHolder(用于Adapter),点击confirm就能自动生成了,建议打开自动导入,这样Android Studio就会自动导入类中的引用和去掉没用的引用 

以下是我的xml布局和生成的类文件

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5. android:layout_width="300dp"
  6. android:layout_height="match_parent"
  7. android:orientation="vertical">
  8. <android.support.v7.widget.CardView
  9. android:layout_width="match_parent"
  10. android:layout_height="wrap_content"
  11. app:cardBackgroundColor="#ffffff"
  12. android:layout_marginTop="10dp"
  13. app:cardElevation="3dp"
  14. app:cardMaxElevation="3dp">
  15. <RelativeLayout
  16. android:layout_width="300dp"
  17. android:layout_height="match_parent">
  18. <ImageView
  19. android:id="@+id/iv_head"
  20. android:layout_width="match_parent"
  21. android:layout_height="300dp"
  22. android:layout_margin="5dp"
  23. android:src="@mipmap/b"
  24. android:scaleType="fitXY"/>
  25. <RelativeLayout
  26. android:layout_width="match_parent"
  27. android:layout_height="wrap_content"
  28. android:layout_alignBottom="@id/iv_head"
  29. android:background="#30000000"
  30. android:padding="5dp"
  31. android:layout_marginLeft="5dp"
  32. android:layout_marginRight="5dp">
  33. <TextView
  34. android:id="@+id/tv_age"
  35. android:layout_width="wrap_content"
  36. android:layout_height="wrap_content"
  37. android:textColor="#ffffff"/>
  38. <TextView
  39. android:id="@+id/tv_height"
  40. android:layout_width="wrap_content"
  41. android:layout_height="wrap_content"
  42. android:layout_marginLeft="15dp"
  43. android:layout_toRightOf="@id/tv_age"
  44. android:textColor="#ffffff"/>
  45. <TextView
  46. android:layout_width="wrap_content"
  47. android:layout_height="wrap_content"
  48. android:textColor="#ffffff"
  49. android:id="@+id/tv_info"
  50. android:layout_alignParentRight="true"/>
  51. </RelativeLayout>
  52. <TextView
  53. android:layout_width="match_parent"
  54. android:layout_height="wrap_content"
  55. android:maxLines="2"
  56. android:layout_below="@id/iv_head"
  57. android:layout_margin="10dp"
  58. android:textSize="22sp"
  59. android:minLines="2"
  60. android:ellipsize="end"
  61. android:id="@+id/tv_desc"
  62. android:textColor="#666666"/>
  63. </RelativeLayout>
  64. </android.support.v7.widget.CardView>
  65. <TextView
  66. android:layout_width="90dp"
  67. android:layout_height="36dp"
  68. android:layout_gravity="top|center_horizontal"
  69. android:background="@drawable/test_bg"
  70. android:gravity="center"
  71. android:textSize="22sp"
  72. android:elevation="6dp"
  73. android:id="@+id/tv_name"
  74. android:textColor="#333333"/>
  75. </FrameLayout>

类文件

  1. package wang.raye.viewdemo.ui;
  2. import android.os.Bundle;
  3. import android.support.v4.app.FragmentActivity;
  4. import android.widget.ImageView;
  5. import android.widget.TextView;
  6. import wang.raye.preioc.PreIOC;
  7. import wang.raye.preioc.annotation.BindById;
  8. import wang.raye.preioc.annotation.OnClick;
  9. import wang.raye.viewdemo.R;
  10. public class Test extends FragmentActivity {
  11. @BindById(R.id.iv_head)
  12. ImageView ivHead;
  13. @BindById(R.id.tv_age)
  14. TextView tvAge;
  15. @BindById(R.id.tv_height)
  16. TextView tvHeight;
  17. @BindById(R.id.tv_info)
  18. TextView tvInfo;
  19. @BindById(R.id.tv_desc)
  20. TextView tvDesc;
  21. @BindById(R.id.tv_name)
  22. TextView tvName;
  23. @Override
  24. protected void onCreate(Bundle savedInstanceState) {
  25. super.onCreate(savedInstanceState);
  26. setContentView(R.layout.activity_test);
  27. PreIOC.binder(this);
  28. }
  29. @OnClick(R.id.iv_head)
  30. public void onClick() {
  31. }
  32. }

Android Studio插件推荐(PreIOC,GsonFormat)的更多相关文章

  1. Android Studio插件推荐-GsonFormat,ButterKnifeZelezny

    原创文章.转载请注明 http://blog.csdn.net/leejizhou/article/details/50557786 本篇介绍的仅仅适用android studio和 Intellij ...

  2. 推荐几款实用的Android Studio 插件

    推荐几款实用的Android Studio 插件 泡在网上的日子 发表于 2015-10-09 10:47 第 17453 次阅读 插件,Android Studio 10 编辑推荐:稀土掘金,这是一 ...

  3. Android studio 插件之 GsonFormat (自己主动生成javabean)

    概述 相信大家在做开发的过程中都写过非常多的javabean ,非常多情况下 都是一个列表数据就是一个单独的javabean.假设大家自己敲的话费时费力 还非常easy敲错. 今天给大家推荐一个插件 ...

  4. 最完整Android Studio插件整理 (转)

    转自:http://blog.csdn.net/alpha58/article/details/62881144 现在Android的开发者基本上都使用android Studio进行开发(如果你还在 ...

  5. 非常有用的开发工具之Android Studio插件

    我们都知道Eclipse开发Android将在今年年底google不再继续提供相应的开发支持,转而开始强烈发展Android Studio,现在我就分享几款能帮助团队提升工作效率的几个Android ...

  6. Android Studio插件:GsonFromat

    这个Android Studio插件可以根据JSONObject格式的字符串,自动生成实体类参数. 具体见:https://github.com/zzz40500/GsonFormat

  7. [精品推荐]Android Studio插件整理

    GOOD 现在Android的开发者基本上都使用Android Studio进行开发(如果你还在使用eclipse那也行,毕竟你乐意怎么样都行).使用好Android Studio插件能大量的减少我们 ...

  8. 自己编写Android Studio插件 别停留在用的程度了(转载)

    转自:自己编写Android Studio插件 别停留在用的程度了 1概述 相信大家在使用Android Studio的时候,或多或少的会使用一些插件,适当的配合插件可以帮助我们提升一定的开发效率,更 ...

  9. android studio 插件

    引用于:http://www.zhihu.com/question/28026027 adb-idea 支持直接在AS面板中进行ADB操作,个人觉得太实用,上面有哥们已提及,这里再介绍下: Unins ...

随机推荐

  1. Android APK反编译详解(附图)

    转载自http://blog.csdn.net/sunboy_2050/article/details/6727581 这段时间在学Android应用开发,在想既然是用Java开发的应该很好反编译从而 ...

  2. String.format中大括号的加入方法

    因为相对于string Builder  自己更喜欢 string.format 的形式拼接字符串。 今天在写代码的时候怎么都报错,弄的我很奇怪 最后发现问题出在字符串中出现大括号“{”的问题,我想这 ...

  3. 【转】PowerShell入门(五):Cmd命令与PowerShell命令的交互

    转至:http://www.cnblogs.com/ceachy/archive/2013/02/18/Call_Between_Cmd_And_PowerShell.html 单独使用一种脚本来完成 ...

  4. 转 C# 装箱和拆箱[整理]

    1.      装箱和拆箱是一个抽象的概念 2.      装箱是将值类型转换为引用类型 :拆箱是将引用类型转换为值类型       利用装箱和拆箱功能,可通过允许值类型的任何值与Object 类型的 ...

  5. 03-组合逻辑电路设计之译码器——小梅哥FPGA设计思想与验证方法视频教程配套文档

    芯航线——普利斯队长精心奉献 课程目标:    1. 再次熟悉Quartus II工程的建立以及完整的FPGA开发流程 2. 以译码器为例学会简单组合逻辑电路设计 实验平台:无 实验原理: 组合逻辑, ...

  6. lucene5.5 field

    lucene常见Field IntField 主要对int类型的字段进行存储,需要注意的是如果需要对InfField进行排序使用SortField.Type.INT来比较,如果进范围查询或过滤,需要采 ...

  7. Apache配置多个网站

    你可以全用本地私有ip地址创建多个站点 127.0.0.x,这个网段的所有ip都是指向本机的,并且可以区分,这是计算机的私有ip地址,供测试用的,配置方法如下 一.打开httpd.conf 1.从Se ...

  8. ShadowGun Demo学习(非技术向)

    主要针对拿来主义,并对一些使用范围广的shader进行研究.虽然是4,5年前的demo,但还是有学习价值的 1.GodRays MADFINGER/Transparent/GodRays 传统的上帝之 ...

  9. 【Tomcat】Tomcat Session在Redis共享

    参考的优秀文章 Redis-backed non-sticky session store for Apache Tomcat 简单地配置Tomcat Session在Redis共享 我使用的是现有的 ...

  10. 20 个值得一试的JavaScript 框架

      投递人 itwriter 发布于 2011-09-26 17:46 评论(3) 有1956人阅读 原文链接 [收藏] « » 本文介绍 20 个值得一试的 JavaScript 框架,如果你认为答 ...