Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>So to pass the <code>ArrayList&lt;Double&gt;</code> from one activity to the other, you have to use the <code>Parcelable</code> interface.</p> <p>You have to create a class called MyDouble for example : </p> <pre><code>public class MyDouble implements Parcelable { Double al; public MyDouble(Parcel source){ al = source.readDouble(); } public MyDouble(Double val){ al = val; } @Override public int describeContents() { // TODO Auto-generated method stub return this.hashCode(); } @Override public void writeToParcel(Parcel dest, int flags) { // TODO Auto-generated method stub dest.writeDouble(al); } public Double getValueDouble(){ return this.al; } public static Parcelable.Creator&lt;MyDouble&gt; CREATOR = new Parcelable.Creator&lt;MyDouble&gt;() { @Override public MyDouble createFromParcel(Parcel source) { // TODO Auto-generated method stub return new MyDouble(source); } @Override public MyDouble[] newArray(int size) { // TODO Auto-generated method stub return new MyDouble[size]; } }; } </code></pre> <p>Instantiate an ArrayList of MyDouble and use :</p> <pre><code>Intent second = new Intent(this, Second.class); ArrayList&lt;MyDouble&gt;al = new ArrayList&lt;MyDouble&gt;(); MyDouble m1 = new MyDouble(2.0); MyDouble m2 = new MyDouble(4.0); al.add(m1); al.add(m2); second.putParcelableArrayListExtra("array_list_test", al); startActivity(second); </code></pre> <p>You retrieve your doubles values, in the other activity by doing : </p> <pre><code>ArrayList&lt;MyDouble&gt; p =b.getParcelableArrayList("array_list_test"); </code></pre> <p>I tested it on my machine and it works that way. Hope it helps.</p> <p>Some documentation : </p> <p><a href="http://developer.android.com/reference/android/os/Parcelable.html" rel="nofollow">http://developer.android.com/reference/android/os/Parcelable.html</a></p> <p><a href="http://prasanta-paul.blogspot.com/2010/06/android-parcelable-example.html" rel="nofollow">http://prasanta-paul.blogspot.com/2010/06/android-parcelable-example.html</a></p> <p><a href="http://blog.cluepusher.dk/2009/10/28/writing-parcelable-classes-for-android/" rel="nofollow">http://blog.cluepusher.dk/2009/10/28/writing-parcelable-classes-for-android/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload