1

In my application I am trying to pass ArrayList from one activity to another activity. how can I do that. please help! any sample.

utta
  • 29
  • 4

1 Answers1

2

There's no method to pass an ArrayList<Float> as an extra, but you can pass a float[]. When creating the Intent to start your second Activity you'll need to convert your ArrayList<Float>.

float[] array = new float[arrayList.size()];

for (int i = 0; i < arrayList.size(); i++) {
  array[i] = arrayList.get(i);
}

Then when you're starting your next Activity

Intent intent = new Intent(this, NextActivity.class);
intent.putExtra("floatArray", array);

In NextActivity, your float[] will be available in the extras. You can obtain it by calling

getIntent().getExtras().getFloatArray("floatArray");
Chris Horner
  • 1,994
  • 2
  • 16
  • 26