【发布时间】:2015-04-24 02:26:53
【问题描述】:
我有一个复杂的类,我使用了@Parcelable(我正在使用 Parceler 库 https://github.com/johncarl81/parceler)
@Parcel
public class Event {
public int id;
public String title;
public String description;
public String resourceURL;
public List<Url> urls;
public Date modified;
public Date start;
public Date end;
public ImageInfo thumbnail;
public ItemList comics;
public ItemList stories;
public ItemList series;
public CharacterList characters;
public CreatorList creators;
public Item next;
public Item previous;
}
该类还有许多其他对象,但它们大多是字符串。
我将它包装在我的主要活动中,例如:
Intent intent = new Intent(getApplicationContext(), EventDescriptionActivity.class);
Bundle bundle = new Bundle();
bundle.putParcelable("event", Parcels.wrap(eventList.get(position)));
intent.putExtras(bundle);
startActivity(intent);
我有一个事件列表 (eventList),我试图将列表中的一个对象发送到另一个活动。
我在我的其他活动中打开它,例如:
Event event = Parcels.unwrap(this.getIntent().getExtras().get("event"));
在我的 onCreate() 中
但是我的参数下面有一条红线:
"unwrap (android.os.Parcelable) in Parcels cannot be applied to (java.lang.Object)"
【问题讨论】:
标签: java android parcelable parceler