【发布时间】:2015-09-05 09:41:26
【问题描述】:
我想通过按钮单击将ArrayList 的LatLng 变量从一个Activity 传递给另一个。
String 可用的那个不工作请帮帮我....
【问题讨论】:
标签: android eclipse google-maps
我想通过按钮单击将ArrayList 的LatLng 变量从一个Activity 传递给另一个。
String 可用的那个不工作请帮帮我....
【问题讨论】:
标签: android eclipse google-maps
将其作为 Parcelable 对象的 ArrayList 传递。
// Put the coordinates
ArrayList<LatLng> coordinates = new ArrayList<>();
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("coordinates", coordinates);
// Get the coordinates
coordinates = bundle.getParcelableArrayList("coordinates");
要将你需要的包传递给你用来调用其他活动的意图对象:
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.putExtras(bundle);
startActivity(intent);
然后在 SecondActivity 的 onCreate 中获取捆绑包:
ArrayList<LatLng> coordinates = getIntent().getParcelableArrayListExtra("coordinates");
【讨论】:
startActivity 来启动SecondActivity吗?