我认为这只是一个愚蠢的错误,但ArrayList
总是结束null
。这让我发疯,所以我想寻求帮助。
对象类:
import android.os.Parcel;
import android.os.Parcelable;
public class StoryTag implements Parcelable {
private String tagTitle;
private int occurrence;
public StoryTag() {
}
public StoryTag(Parcel in) {
tagTitle = in.readString();
occurrence = in.readInt();
}
public String getTagTitle() {
return tagTitle;
}
public void setTagTitle(String tagstring) {
this.tagTitle = tagstring;
}
public int getOccurrence() {
return occurrence;
}
public void setOccurrence(int occurrence) {
this.occurrence = occurrence;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(tagTitle);
dest.writeInt(occurrence);
}
public int describeContents() {
return 0;
}
public static final Parcelable.Creator<StoryTag> CREATOR = new Parcelable.Creator<StoryTag>() {
public StoryTag createFromParcel(Parcel in) {
return new StoryTag(in);
}
public StoryTag[] newArray(int size) {
return new StoryTag[size];
}
};
}
MainActivity
:
Intent tagIntent=new Intent(this,DisplayTagList.class);
tagIntent.putExtra("taglist", taglist);
startActivity(tagIntent);
return true;
接收活动:
Bundle storyTagBundle = getIntent().getExtras();
ArrayList<StoryTag> listoftags = storyTagBundle.getParcelable("taglist");
非常感谢您提供的任何帮助。把我的头发拉到这里是因为我认为这是一个小错误。