是否可以将GoogleMap对象从一个活动移动到另一个活动? [英] Is it possible to move a GoogleMap object from one activity to another?

查看:170
本文介绍了是否可以将GoogleMap对象从一个活动移动到另一个活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的主要活动中,我实例化了一个GoogleMap对象。



按下按钮,在我的下一个Acivity中,我也有一个GoogleMap对象。



我想知道是否可以使用同一个对象,而不必创建新的GoogleMap对象并再次进行相应的设置。



基本上我不想在两次不同的活动中做两次同样的事情,并且表现很好。



我知道可以通过intents,extras,bundles等来移动数据,但我找不到有关GoogleMaps或传递实际非字符串化对象的信息。



干杯。

解决方案

即使您可以将对象传递给另一个活动,也需要另一个在您的第二个活动中映射xml ,它将引用 Google地图对象。另一个解决方案是有一个静态的地图对象,这不是一个好的做法,我不会推荐它。


So in my main activity I have instantiated a GoogleMap object.

On button click, in my next Acivity, I also have a GoogleMap object.

I want to know if it's possible to use the same object and not have to create a new GoogleMap object and do the appropriate set-up again.

Basically I don't want to do the same thing twice in two different activities and take the performance hit.

I know it's possible to move data via intents, extras, bundles etc. but I can't find information regarding GoogleMaps or passing actual non-stringified objects.

Cheers.

解决方案

Even if you can pass the object to another activity, you need to have another instance of map xml in your second activity which will have a reference to google map object. Another solution is to have a static object of map which is not a good practice and I wont recommend it.

这篇关于是否可以将GoogleMap对象从一个活动移动到另一个活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆