Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

How to pass ArrayList of Objects from one to another activity using Intent in android?

//make your class implement Parcelable
public class PanierClassInfo implements Parcelable{
// here attribute
//.......

// the following method is just an example and depend on class atribute, it generated 
//just make class implement parcelable then wait
// until your class give error show that you have add some implements alt + enter then
// all will be ok

    protected PanierClassInfo(Parcel in) {
        quantity = in.readInt();
        comment = in.readString();
    }
}

// from first Activity put this:
 Intent intent=new Intent(RestaurantClickedActivity.this, CheckOutActivity.class);
 Bundle args = new Bundle();
 args.putParcelableArrayList("ARRAYLIST",listPanier);
 intent.putExtra("BUNDLE",args);
 startActivity(intent);
 
// the destination activity do this:
List<PanierClassInfo> questions = new ArrayList<PanierClassInfo>();
 Intent intent = getIntent();
 Bundle args = intent.getBundleExtra("BUNDLE");
 questions = args.getParcelableArrayList("ARRAYLIST");
 
 // if you faced kind of problem please try to contact me ;)
 
PREVIOUS NEXT
Tagged: #How #pass #ArrayList #Objects #activity #Intent
ADD COMMENT
Topic
Name
4+8 =