AS插件-Android Parcelable code generator.
生活随笔
收集整理的這篇文章主要介紹了
AS插件-Android Parcelable code generator.
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
概述
生成實現了Parcelable接口的代碼的插件
下載安裝
1.在線安裝
輸入 Android Parcelable code generator ,點擊安裝即可,安裝之后 重啟,會看到上圖選中部分所示。
2.手動下載安裝
https://github.com/mcharmas/android-parcelable-intellij-plugin
使用
在你的類中,按下alt + insert鍵彈出插入代碼的上下文菜單,會看到在下面有一個Parcelable,選擇它之后,就會在你的類當中插入實現了Parcelable接口的代碼了。
經驗證,勾選Product的3個變量 和不選,生成的代碼是一樣的。
代碼如下(setter+getter是之前已經寫好了的)
package com.turing.base.activity.test;import android.os.Parcel; import android.os.Parcelable;/*** MyApp** @author Mr.Yang on 2016-04-13 22:32.* @version 1.0* @desc*/ public class Product implements Parcelable {private int id;private String name;private float price;public int getId() {return id;}public void setId(int id) {this.id = id;}public String getName() {return name;}public void setName(String name) {this.name = name;}public float getPrice() {return price;}public void setPrice(float price) {this.price = price;}@Overridepublic int describeContents() {return 0;}@Overridepublic void writeToParcel(Parcel dest, int flags) {dest.writeInt(this.id);dest.writeString(this.name);dest.writeFloat(this.price);}public Product() {}protected Product(Parcel in) {this.id = in.readInt();this.name = in.readString();this.price = in.readFloat();}public static final Creator<Product> CREATOR = new Creator<Product>() {@Overridepublic Product createFromParcel(Parcel source) {return new Product(source);}@Overridepublic Product[] newArray(int size) {return new Product[size];}}; }總結
以上是生活随笔為你收集整理的AS插件-Android Parcelable code generator.的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AS插件-Android Layout
- 下一篇: AS插件-android-selecto