标签:
1 package com.gaojinhua.android.activitymsg; 2 3 import android.os.Parcel; 4 import android.os.Parcelable; 5 6 /** 7 * Created by Gaojinhua on 2015/8/14. 8 */ 9 public class User implements Parcelable { 10 private String name; 11 private int age; 12 13 public User(String name, int age) { 14 this.name = name; 15 this.age = age; 16 } 17 18 19 public void setName(String name) { 20 this.name = name; 21 } 22 23 public String getName() { 24 return name; 25 } 26 27 public void setAge(int age) { 28 this.age = age; 29 } 30 31 public int getAge() { 32 return age; 33 } 34 35 @Override 36 public int describeContents() { 37 return 0; 38 } 39 40 @Override 41 public void writeToParcel(Parcel dest, int flags) { 42 dest.writeString(getName()); 43 dest.writeInt(getAge()); 44 } 45 46 public static final Creator<User> CREATOR = new Creator<User>() { 47 @Override 48 public User createFromParcel(Parcel source) { 49 return new User(source.readString(), source.readInt()); 50 } 51 52 @Override 53 public User[] newArray(int size) { 54 return new User[size]; 55 } 56 }; 57 58 59 }
Android对象类系列化public class User implements Parcelable
标签:
原文地址:http://www.cnblogs.com/gaojinhua/p/4731456.html