我有一个活动A,它有一个我可以参与的对象的ArrayList .. 对象是:
public class DashBoardPOJO implements Parcelable {
private String dashBoardName;
private String dashBoardId;
private String dashBoardStatus;
private ArrayList<DashBoardDataPOJO> dashBoardDataList;
private boolean loaded;
public ArrayList<DashBoardDataPOJO> getDashBoardDataList() {
return dashBoardDataList;
}
public void setDashBoardDataList(
ArrayList<DashBoardDataPOJO> dashBoardDataList) {
this.dashBoardDataList = dashBoardDataList;
}
public boolean isLoaded() {
return loaded;
}
public void setLoaded(boolean loaded) {
this.loaded = loaded;
}
public String getDashBoardStatus() {
return dashBoardStatus;
}
public void setDashBoardStatus(String dashBoardStatus) {
this.dashBoardStatus = dashBoardStatus;
}
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(dashBoardName);
dest.writeString(dashBoardId);
dest.writeList(dashBoardDataList);
}
public static final Parcelable.Creator<DashBoardPOJO> CREATOR = new Parcelable.Creator<DashBoardPOJO>() {
public DashBoardPOJO createFromParcel(Parcel in) {
return new DashBoardPOJO(in);
}
public DashBoardPOJO[] newArray(int size) {
return new DashBoardPOJO[size];
}
};
public DashBoardPOJO() {
dashBoardName = null;
dashBoardId = null;
dashBoardDataList = null;
/*
* userName=null; userId=null;
*/
}
private DashBoardPOJO(Parcel in) {
dashBoardName = in.readString();
dashBoardId = in.readString();
in.readList(dashBoardDataList, null);
}
// GETTERS AND SETTERS............
public String getDashBoardName() {
return dashBoardName;
}
public void setDashBoardName(String dashBoardName) {
this.dashBoardName = dashBoardName;
}
public String getDashBoardId() {
return dashBoardId;
}
public void setDashBoardId(String dashBoardId) {
this.dashBoardId = dashBoardId;
}
}
我想将ArrayList传递给扩展Fragment Activity的活动。
我发送像这样的对象
Intent intent = new Intent(
DashboardActivity.this,
BaseFragmentActivity.class);
intent.putParcelableArrayListExtra("dashBoardList", dashBoardList);
startActivity(intent);
在像这样的片段活动中接收它
dashboardList = getIntent().getExtras().getParcelableArrayList("dashBoardList");
但仍然意图是返回给我一个空值......请帮忙......
答案 0 :(得分:0)
试试这个:
private DashBoardPOJO(Parcel in) {
dashBoardName = in.readString();
dashBoardId = in.readString();
dashBoardDataList = (ArrayList<DashBoardDataPOJO>) in.readArrayList(DashBoardDataPOJO.class.getClassLoader());
}