ArrayList<Item> arrayOfList;
I want to pass arrayOfList;
to next activity on Itemclick
of listview
Tried Things
Intent sec = new Intent(this, IndividualPage.class);
Bundle b = new Bundle();
b.putParcelableArrayList("mylist", arrayOfList);
sec.putExtras(b);
To retrieve the arraylist
Bundle b = this.getIntent().getExtras();
ArrayList<Item> cats = b.getParcelableArrayList("mylist");
System.out.println(cats);
But i am getting null
in console.
Is there any other efficient way to pass the data.
Item.java
public class Item implements Parcelable {
private String Name;
private String Location;
private String Image;
private String Sector;
private int Founded;
private String Status;
private int RowVAls;
public String getName() {
return Name;
}
public void setName(String Name) {
this.Name = Name;
}
public String getLocation() {
return Location;
}
public void setLocation(String Location) {
this.Location = Location;
}
public String getImage() {
//return "http://23.253.164.20:8099/"+Image;
return "http://23.253.164.20:8099/"+Image;
}
public void setImage(String Image) {
this.Image = Image;
}
public String getSector() {
return Sector;
}
public void setSector(String Sector) {
this.Sector = Sector;
}
public int getFounded() {
return Founded;
}
public void setFounded(int Founded) {
this.Founded = Founded;
}
public String getStatus() {
return Status;
}
public void setStatus(String Status) {
this.Status = Status;
}
public int getRowVAls() {
return RowVAls;
}
public void setRowVAls(int RowVAls) {
this.RowVAls = RowVAls;
}
protected Item(Parcel in) {
Name = in.readString();
Location = in.readString();
Image = in.readString();
Sector = in.readString();
Founded = in.readInt();
Status = in.readString();
RowVAls = in.readInt();
}
@SuppressWarnings("unused")
public static final Parcelable.Creator<Item> CREATOR = new Parcelable.Creator<Item>() {
@Override
public Item createFromParcel(Parcel in) {
return new Item(in);
}
@Override
public Item[] newArray(int size) {
return new Item[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(Name);
dest.writeString(Location);
dest.writeString(Image);
dest.writeString(Sector);
dest.writeInt(Founded);
dest.writeString(Status);
dest.writeInt(RowVAls);
}
Note:- Item is neither Parcelable
nor Serializable
.
And i would not like to make any changes in that.