Android Studio插件推荐(PreIOC,GsonFormat)
好的插件能加快项目的开发速度,尤其是一些针对重复性的代码的插件,所以在这里向大家推荐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
- {
- "people":[
- {"firstName":"Brett","lastName":"McLaughlin","email":"aaaa"},
- {"firstName":"Jason","lastName":"Hunter","email":"bbbb"},
- {"firstName":"Elliotte","lastName":"Harold","email":"cccc"}
- ]
- }
JavaBean
- package wang.raye.viewdemo.bean;
- import java.util.List;
- /**
- * Created by Raye on 2016/3/28.
- */
- public class JsonBean {
- /**
- * firstName : Brett
- * lastName : McLaughlin
- * email : aaaa
- */
- private List<PeopleBean> people;
- public List<PeopleBean> getPeople() {
- return people;
- }
- public void setPeople(List<PeopleBean> people) {
- this.people = people;
- }
- public static class PeopleBean {
- private String firstName;
- private String lastName;
- private String email;
- public String getFirstName() {
- return firstName;
- }
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
- public String getLastName() {
- return lastName;
- }
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- }
- }
怎么样很方便吧,下面介绍PreIOC
PreIOC
PreIOC是针对PreIOC框架的一个插件,PreIOC是一个预编译的注解框架,关于详细的PreIOC相关资料可以去主页查看git.oschina或者github
第一步:安装
同前面gsonFormat的安装差不多,不过搜索的时候需要搜索PreIOC,目前关于PreIOC的结果只有一个,所以可以选择安装
第二步:使用
使用PreIOC有个前提,就是项目必须要使用了PreIOC 1.0.6版本,之前的老版本不予支持,同时为了避免Bug建议切换到新版,使用PreIOC 1.0.6
- 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布局和生成的类文件
- <?xml version="1.0" encoding="utf-8"?>
- <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="300dp"
- android:layout_height="match_parent"
- android:orientation="vertical">
- <android.support.v7.widget.CardView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- app:cardBackgroundColor="#ffffff"
- android:layout_marginTop="10dp"
- app:cardElevation="3dp"
- app:cardMaxElevation="3dp">
- <RelativeLayout
- android:layout_width="300dp"
- android:layout_height="match_parent">
- <ImageView
- android:id="@+id/iv_head"
- android:layout_width="match_parent"
- android:layout_height="300dp"
- android:layout_margin="5dp"
- android:src="@mipmap/b"
- android:scaleType="fitXY"/>
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@id/iv_head"
- android:background="#30000000"
- android:padding="5dp"
- android:layout_marginLeft="5dp"
- android:layout_marginRight="5dp">
- <TextView
- android:id="@+id/tv_age"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="#ffffff"/>
- <TextView
- android:id="@+id/tv_height"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginLeft="15dp"
- android:layout_toRightOf="@id/tv_age"
- android:textColor="#ffffff"/>
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textColor="#ffffff"
- android:id="@+id/tv_info"
- android:layout_alignParentRight="true"/>
- </RelativeLayout>
- <TextView
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:maxLines="2"
- android:layout_below="@id/iv_head"
- android:layout_margin="10dp"
- android:textSize="22sp"
- android:minLines="2"
- android:ellipsize="end"
- android:id="@+id/tv_desc"
- android:textColor="#666666"/>
- </RelativeLayout>
- </android.support.v7.widget.CardView>
- <TextView
- android:layout_width="90dp"
- android:layout_height="36dp"
- android:layout_gravity="top|center_horizontal"
- android:background="@drawable/test_bg"
- android:gravity="center"
- android:textSize="22sp"
- android:elevation="6dp"
- android:id="@+id/tv_name"
- android:textColor="#333333"/>
- </FrameLayout>
类文件
- package wang.raye.viewdemo.ui;
- import android.os.Bundle;
- import android.support.v4.app.FragmentActivity;
- import android.widget.ImageView;
- import android.widget.TextView;
- import wang.raye.preioc.PreIOC;
- import wang.raye.preioc.annotation.BindById;
- import wang.raye.preioc.annotation.OnClick;
- import wang.raye.viewdemo.R;
- public class Test extends FragmentActivity {
- @BindById(R.id.iv_head)
- ImageView ivHead;
- @BindById(R.id.tv_age)
- TextView tvAge;
- @BindById(R.id.tv_height)
- TextView tvHeight;
- @BindById(R.id.tv_info)
- TextView tvInfo;
- @BindById(R.id.tv_desc)
- TextView tvDesc;
- @BindById(R.id.tv_name)
- TextView tvName;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_test);
- PreIOC.binder(this);
- }
- @OnClick(R.id.iv_head)
- public void onClick() {
- }
- }
Android Studio插件推荐(PreIOC,GsonFormat)的更多相关文章
- Android Studio插件推荐-GsonFormat,ButterKnifeZelezny
原创文章.转载请注明 http://blog.csdn.net/leejizhou/article/details/50557786 本篇介绍的仅仅适用android studio和 Intellij ...
- 推荐几款实用的Android Studio 插件
推荐几款实用的Android Studio 插件 泡在网上的日子 发表于 2015-10-09 10:47 第 17453 次阅读 插件,Android Studio 10 编辑推荐:稀土掘金,这是一 ...
- Android studio 插件之 GsonFormat (自己主动生成javabean)
概述 相信大家在做开发的过程中都写过非常多的javabean ,非常多情况下 都是一个列表数据就是一个单独的javabean.假设大家自己敲的话费时费力 还非常easy敲错. 今天给大家推荐一个插件 ...
- 最完整Android Studio插件整理 (转)
转自:http://blog.csdn.net/alpha58/article/details/62881144 现在Android的开发者基本上都使用android Studio进行开发(如果你还在 ...
- 非常有用的开发工具之Android Studio插件
我们都知道Eclipse开发Android将在今年年底google不再继续提供相应的开发支持,转而开始强烈发展Android Studio,现在我就分享几款能帮助团队提升工作效率的几个Android ...
- Android Studio插件:GsonFromat
这个Android Studio插件可以根据JSONObject格式的字符串,自动生成实体类参数. 具体见:https://github.com/zzz40500/GsonFormat
- [精品推荐]Android Studio插件整理
GOOD 现在Android的开发者基本上都使用Android Studio进行开发(如果你还在使用eclipse那也行,毕竟你乐意怎么样都行).使用好Android Studio插件能大量的减少我们 ...
- 自己编写Android Studio插件 别停留在用的程度了(转载)
转自:自己编写Android Studio插件 别停留在用的程度了 1概述 相信大家在使用Android Studio的时候,或多或少的会使用一些插件,适当的配合插件可以帮助我们提升一定的开发效率,更 ...
- android studio 插件
引用于:http://www.zhihu.com/question/28026027 adb-idea 支持直接在AS面板中进行ADB操作,个人觉得太实用,上面有哥们已提及,这里再介绍下: Unins ...
随机推荐
- 一个Demo学完Android中所有的服务(转)
说明:这个例子实现了Android中常见的许多服务,下面是实现的截图 接下来,以源代码的方式分析这个例子 1.MainActivity--主界面 这个类主要是实现用户所看到的这个Activity, ...
- android的listview的详细用法
listview是android开发中的一个极其重要的控件.所以,要学会android,如果这个不会,基本是不会android的. 这里按照几个步骤介绍这个控件的使用. 1. 使用API中ArrayA ...
- 在学Go语言
首发:个人博客,更新&纠错&回复 开始学点儿Go语言,这语言据说在国内比在国外火,社区上褒贬不一,不过“小马过河”嘛,总要先自己试试再来下结论. 环境准备: 1.在Golang中国下载 ...
- ADO.NET 新特性之SqlBulkCopy
在.Net1.1中无论是对于批量插入整个DataTable中的所有数据到数据库中,还是进行不同数据源之间的迁移,都不是很方便.而 在.Net2.0中,SQLClient命名空间下增加了几个新类帮助我们 ...
- 初识Python第二天(4)
'.isdecimal()) print('壹'.isdecimal()) print('11d'.isdecimal()) #True #False #False #只有全部为unicode数字,全 ...
- python(二)数据类型
一.整数 创建方法 i = 10 i = int(10) i = int("10",base=2) #“”中是几进制的表示,base是选择要表示的进制,如base=2,用2进制的 ...
- 【设计模式】常用de单例模式
> 单例模式 单例模式,是常见的设计模式之一,一般来说,是程序员较早接触的模式之一.嘻嘻,包括我~~~ > 分类 一般来说,分两种: 饿汉模式.非常饿嘛,一上来就加载了,所以,就是非延迟加 ...
- EFS加密解密----重装系统后
重装系统尤其是格式化重装系统之后,如果没有正确地备份私钥,那么加密的文件将无法打开,加密的文件也暂时没有办法进行快速破解. 并非重装后用相同用户名+密码就可以解密的. Advanced EFS Dat ...
- Popwindow
popwindow的使用方法 View contentView = LayoutInflater.from(mContext).inflate( R.layout.dialog_homelist_vi ...
- Winform开发框架之介绍
winform开发框架,尽量减少程序员在界面中的代码量和工作量,Model自动生成,界面以及控件自动生成,简单的逻辑自动生成.自动生成的界面已经实现简单逻辑增删改查功能. 其他开发框架都已经或多火烧实 ...