Search
 
SCRIPT & CODE EXAMPLE
 

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 ;)
Comment

PREVIOUS NEXT
Code Example
Java :: initialcontext tomcat bug 
Java :: springBoot ConditionalOnMissingBean 
Java :: Java pollfirst() and pollLast() Methods 
Java :: java supress unchecked 
Java :: search in jdbc 
Java :: what does put extra do? 
Java :: why left+(right-left)/2 will not overflow? 
Java :: how to not allow a user to enter a mark greater than 100 or below 0 in java 
Java :: Maven test failure sure fire solved 
Java :: print current user roles in java 
Java :: flutter android studio Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema 
Java :: codegrepper java instanceof 
Java :: Android: how to mark my app as debuggable? 
Java :: find largest number in 2d array java 
Java :: java equivalent of pythons getattr 
Java :: custom class level annotation in spring 
Java :: kivy menu bar 
Java :: java radom float 
Java :: Double And Char In Java 
Java :: add element to arraylist of arraylist in java 
Java :: Statement sql= clsConexion.getConexion().createStatement(); 
Java :: java int data type 
Java :: android api 21 join list of strings 
Java :: class BuildConfig is public, should be declared in a file named BuildConfig.java 
Java :: verificar numero par ou impar jacva 
Java :: java difrence betwen x++ and ++x 
Java :: comparable interface 
Java :: how to code the overdraft limit in Java 
Java :: random number in java between 10 and 20 
Java :: spring environment null pointer exception 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =