在标签布局转移2活动之间的数据 [英] transfer data between 2 activities in a tab layout

查看:84
本文介绍了在标签布局转移2活动之间的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现一个健身应用。我对这个应用程序选项卡的布局,第一个选项卡显示的位置(经度,纬度),速度等状态,第二个选项卡显示了谷歌地图,运行路线将显示在地图上的折线。

I am implementing a fitness app. I have a tab layout for this app, the first tab shows the location(latitude, longitude), speed and other status, and the second tab shows a google map where the running route will be shown as a polyline in the map.

第一个选项卡活动都有接收新位置的位置经理。

The first tab activity has a location manager that receive the new location.

我的问题是:我如何在第一个选项卡活动从位置管理器接收到的数据传送到谷歌地图标签活动

My question is: how can I transfer the data received from the location manager in the first tab activity to the google map tab activity?

,因为我知道用intent.putExtra()和startActivity()可以在2活动之间传输数据,而通过调用startActivity()我只想马上去地图的活动吧?但我想在地图更新折线和留在状态选项卡。

As I know, by using intent.putExtra() and startActivity() can transfer data between 2 activities, but by calling startActivity() I will just immediately go to the map activity right? But I want to update the polyline in the map and stay in the status tab.

任何提示?

在此先感谢:)

推荐答案

创建一个全局类声明静态varible 和值分配给它,并使用另一个类。
而另一种方法

Create One Global class and declare static varible and assign value to it and use another class. And another way

Intent i =new Intent()setClass(this, ListViewerIncompleted.class);
i.putStringArrayListExtra(name, value);

这篇关于在标签布局转移2活动之间的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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