Android Studio插件推荐(PreIOC,GsonFormat)
来源:互联网 发布:初学者羽毛球拍知乎 编辑:程序博客网 时间:2024/05/24 01:45
好的插件能加快项目的开发速度,尤其是一些针对重复性的代码的插件,所以在这里向大家推荐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
- Android Studio插件推荐-GsonFormat,ButterKnifeZelezny
- Android Studio GsonFormat 插件
- Android Studio插件Gsonformat使用
- android studio 插件之 GsonFormat
- Android Studio 安装GsonFormat 插件
- Android Studio插件之GsonFormat
- Android Studio GsonFormat插件的使用
- Android studio使用简单的GsonFormat插件
- Android Studio 插件 —— GsonFormat
- Android Studio插件GsonFormat快速实现JavaBean
- Android studio插件GsonFormat 的使用
- Android Studio 优秀插件(一):GsonFormat
- Android studio插件下载(GsonFormat)
- Android studio插件GsonFormat 的使用
- Android studio插件GsonFormat的使用
- Android studio插件GsonFormat 的使用
- MediaWiki功能使用
- Java环境搭建
- Android无线调试(Android wireless debugging)
- Spark集群运行模式
- Android实现自动填充验证码
- Android Studio插件推荐(PreIOC,GsonFormat)
- [ULK11]信号(三):从信号传递到原程序恢复执行
- 由使用多态引发的一些思考
- UIDatePicker得到的时间中怎么去掉时分秒(字符串操作知识拓展)--iOS开发
- Linux 线程同步的三种方法
- day24
- android ContentProviders
- 使用 Cocos2d-x 和粒子编辑器实现场景特效
- install tetgen on windows