问题描述:

I want to pass an ArrayList of LatLng variables from one Activity to another through button click.

The one available for String is not working Please help me out....

网友答案:

Pass it as an ArrayList of Parcelable objects.

// Put the coordinates
ArrayList<LatLng> coordinates = new ArrayList<>();
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("coordinates", coordinates);

// Get the coordinates
coordinates = bundle.getParcelableArrayList("coordinates");

To pass the bundle you need to the intent object you use to invoke the other activity:

Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.putExtras(bundle);
startActivity(intent);

Then in the SecondActivity's onCreate you fetch the bundle:

ArrayList<LatLng> coordinates = getIntent().getParcelableArrayListExtra("coordinates");
网友答案:

I think you should parceble class or getParceble()

check following link:link 1

link 2

相关阅读:
Top