开发学院手机开发Android 开发 Android中Intent传递对象的两种方法(Serializable... 阅读

Android中Intent传递对象的两种方法(Serializable,Parcelable)

 2010-10-19 20:18:07 来源:WEB开发网   
核心提示:import android.os.Parcel;import android.os.Parcelable;public class Book implements Parcelable {private String bookName;private String author;private int publish

import android.os.Parcel;

import android.os.Parcelable;

public class Book implements Parcelable {

private String bookName;

private String author;

private int publishTime;

public String getBookName() {

return bookName;

}

public void setBookName(String bookName) {

this.bookName = bookName;

}

public String getAuthor() {

return author;

}

public void setAuthor(String author) {

this.author = author;

}

public int getPublishTime() {

return publishTime;

}

public void setPublishTime(int publishTime) {

this.publishTime = publishTime;

}

public static final Parcelable.Creator CREATOR = new Creator() {

public Book createFromParcel(Parcel source) {

Book mBook = new Book();

mBook.bookName = source.readString();

mBook.author = source.readString();

mBook.publishTime = source.readInt();

return mBook;

}

public Book[] newArray(int size) {

return new Book[size];

}

};

public int describeContents() {

return 0;

}

public void writeToParcel(Parcel parcel, int flags) {

parcel.writeString(bookName);

parcel.writeString(author);

parcel.writeInt(publishTime);

}

}

package com.tutor.objecttran;

import android.os.Parcel;

import android.os.Parcelable;

public class Book implements Parcelable {

private String bookName;

private String author;

private int publishTime;

public String getBookName() {

return bookName;

}

public void setBookName(String bookName) {

上一页  1 2 3 4 5 6 7 8  下一页

Tags:Android Intent 传递

编辑录入:爽爽 [复制链接] [打 印]
[]
  • 好
  • 好的评价 如果觉得好,就请您
      0%(0)
  • 差
  • 差的评价 如果觉得差,就请您
      0%(0)
赞助商链接