1.一个序列化生成器,直接可以用http://parcelabler.com/
2.另外一个第三方的Parcelable代码生成器,挺好用的
- Open the parcelabler tool.
- Copy the full code of the class into the “Code” text field.
Example code:public class Photo { /** * Caption for the photo */ public String caption; public int commentCount; public long photoId; public boolean isDefault; public Bundle metadata; public CommentHandler commentHandler; }
- Click “Build” to create the methods
- Copy the methods into your class
- Add “implements Parcelable” to your class definition
Now you should hopefully have a working implementation of Parcelable in your class.