简体   繁体   English

来自MainActivity的数据的新并行活动

[英]New parallel activity with data from the MainActivity

I am newbie in Android development. 我是Android开发的新手。 I have an idea to create an application, which basically has 2 activities: Main and Map. 我有一个创建应用程序的想法,该应用程序基本上有2个活动:Main和Map。 In Main activity the data collection and processing are going to be done. 在主要活动中,将完成数据收集和处理。 So it has all the fields and methods to get data, store it and update. 因此,它具有获取数据,存储和更新数据的所有字段和方法。 It also has a small UI to display this data. 它还具有一个小的UI来显示此数据。 In Map activity I want to have a real-time reflection of the data from MainActivity on the map. 在“地图”活动中,我想实时反映MainActivity在地图上的数据。 So, when the data in MainActivity changes, it should also change in Map activity in real-time. 因此,当MainActivity中的数据更改时,其Map活动中的数据也应实时更改。 The data itself includes location of certain devices in the building and their states. 数据本身包括建筑物中某些设备的位置及其状态。 I couldn't quite understand, if it is possible on Android to start a new Activity in parallel with MainActivity, which will be able to get changing data from MainActivity. 我不太了解,如果Android上有可能与MainActivity并行启动一个新的Activity,它将能够从MainActivity获取更改的数据。 Can anybody advise my something for this issue? 有人可以建议我解决这个问题吗? Thanks in advance. 提前致谢。

You can use Fragments. 您可以使用片段。

Google has several samples in the IDE you can use if you think the Android documentation is hard to understand. 如果您认为Android文档难以理解,那么Google可以在IDE中提供一些示例。

Using master flow(sample) uses a fragment on tablets to display contents side-by-side(list and content in that example). 使用主流程(样本)在平板电脑上使用一个片段来并排显示内容(该示例中的列表和内容)。 But there are other samples as well using Fragments, and there is of course the Android documentation on Fragments as well. 但是也有使用Fragments的其他示例,当然也有关于FragmentsAndroid文档

See also these links: 另请参阅以下链接:

Building a Dynamic UI with Fragments 使用片段构建动态UI

Creating a Fragment 创建片段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM