地图活动单一地图视图
我有一个地图视图,地图上有一些标记和主页的后退按钮。 我还有一个文本视图列表,当选择它时,它将打开一个新页面,其中有一个按钮“查看地图”。 “查看地图”按钮将打开地图。 每个选定的页面都有不同的地图视图,其上有不同的标记。
问题是:
当我选择文本视图列表和“查看地图”按钮时,它工作正常。按钮背面也功能良好。但是,当我选择另一个列表并单击按钮查看地图时,会出现调试强制关闭。我寻找解决方案,DDMS 显示“您只能在地图活动中拥有单个地图视图”。我将如何用更简单的方法解决这个问题,而无需创建另一个类或在 android 清单中创建新的活动。
I have a map views which is have some markers on the map and a back button to the main page.
I also have a list of textview which is when selected, it will open a new page that have a button "View Map". The button "view map" will open up a map.
Each selected page has different map view which is different markers on it.
The problem is :
It works fine when I select the list of textview and "view map" button. The button back also functioning well. However, when i select another list and click the button view map, debug force close appear. I look for the solutions and the DDMS shows that "you are only allowed to have a single mapview in a mapactivity". How i'm going to fix this problem with the simpler ways without create another class or create new activity in android manifest.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以某种方式重构您的地图活动,以便您可以向其传递一堆数据,其中包含有关要显示的位置的信息。通过这样做,您可以动态地在地图上标记不同的地点集。为此,您可以在 Overlay 地图活动中的类,或者为每组标记一个自己的 叠加层 类。
这应该使得多次使用一个 MapView 成为可能。
您应该避免的另一件事是显示后退按钮。通常您不需要一个,因为每台 Android 设备都设计有一个后退按钮。因此,另一个后退按钮可能会让您的用户感到困惑。
Refactor your map activity in a way so you can pass a bunch of data to it which will contain the information about the locations to be displayed. By doing this you can mark different sets of places on you map dynamically. For this you can either use on Overlay class in you map activity or for each set of markers an own Overlay class.
This should made it possible to use one MapView multiple times.
Another thing you should avoid is displaying a back button. Normally you don't need one as every Android device has a back button by design. So another back button might confuse your users.