我想在我的应用程序中将Team
类型的对象传递给另一个Activity
。如何使用parcelable将对象从一个Android活动发送到另一个活动?
的Team
类:
TreeMap<String, HashMap<Integer, ArrayList<Event>>> matchDays;
如何传递嵌套TreeMap中与班上其他同学一起:
public class Team implements Parcelable {
String teamName;
//Name and Link to competition of Team
TreeMap<String, String> competitions;
//Name of competition with a map of matchdays with all games to a matchday
TreeMap<String, HashMap<Integer, ArrayList<Event>>> matchDays;
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(teamName);
dest.writeMap(competitions);
}
public static final Parcelable.Creator<Team> CREATOR = new Parcelable.Creator<Team>() {
public Team createFromParcel(Parcel in) {
return new Team(in);
}
public Team[] newArray(int size) {
return new Team[size];
}
};
private Team(Parcel in) {
teamName = in.readString();
in.readMap(competitions, Team.class.getClassLoader());
}
}
我编组时收到一个RuntimeException?
什么是事件? Event类是可序列化的吗? – kosa 2012-07-06 20:23:10