I've stored ArrayList<Double>
on my bean class,
I've the bean class on my main activity,
How to pass the ArrayList<Double>
,from my main activity to another activity.?
My array list is double. how to pass double arraylist ?
I've stored ArrayList<Double>
on my bean class,
I've the bean class on my main activity,
How to pass the ArrayList<Double>
,from my main activity to another activity.?
My array list is double. how to pass double arraylist ?
This one helps you...
public Intent putParcelableArrayListExtra (String name, ArrayList<? extends Parcelable> value)
For more info look at putParcelableArrayListExtra
EDIT:
If you have a double[]
then you can use
void putDoubleArray(String key, double[] value)
of Bundle class..
Inserts a double array value into the mapping of this Bundle, replacing any existing value for the given key. And pass this bundle to Intent to Other Activity.
Update:2
FirstActivity:
Intent intent = new Intent(this, OtherActivity.class);
ArrayList<Double> listDouble = new ArrayList<Double>();
listDouble.add(1111.00000);
listDouble.add(13331.00000);
intent.putExtra("arraylist", listDouble);
startActivity(intent);
OtherActivity: (Retrieve Double ArrayList)
ArrayList<Double> listDouble = (ArrayList<Double>) getIntent().getSerializableExtra("arraylist");
System.out.println("...serialized data.." + listDouble);
Refer below method to pass data from one activity to other
Eg 1
putIntegerArrayListExtra(String name, ArrayList<Integer> value)
putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value)
putStringArrayListExtra(String name, ArrayList<String> value)
putCharSequenceArrayListExtra(String name, ArrayList<CharSequence> value)
Then you can read from you next activity by replacing put with get with key string as argument,eg
myIntent.getStringArrayListExtra("array");
Eg 2
Intent i = new Intent(this,name.class);
Bundle b = new Bundle();
b.putIntegerArrayListExtra(String name, ArrayList<Integer> value);
//b.putParcelableArrayListExtra(String name, ArrayList<? extends Parcelable> value);
//b.putStringArrayListExtra(String name, ArrayList<String> value);
i.putExtra(String name,b);
startActivity(i);
You should consider passing parameters to an other activity though Intent Extras :
Intent.putExtra()
This code will demonstrate that how to pass a double array object to other activity through inent
String [] my_dblArray=new Sting[no];
//put some value in the array and then pass through intent
Intent intnt=new Intent(this,YourReqActivity.class);
Bundle bundle = new Bundle();
bundle.putDoubleArray("doubleVal",my_dblArray);
intnt.putExtra(bundle);
startActivity(intnt);
// At Receiver side put this line of code.
String [] dblval=Bndl.getDoubleArray("doubleVal");