Multiple maps v2 in TabActivity

后端 未结 2 570
终归单人心
终归单人心 2020-12-28 08:42

I\'m currently trying to have 2 maps v2 in different tabs of a TabActivity using MapView objects. The problem arises in the following scenario:

  • tab1 with a map
相关标签:
2条回答
  • 2020-12-28 09:26

    I ran into the same issue a few days ago and was pulling my hair out over what to do.

    Originally I had my app set up with "Tabs the Fragment way" as seen here to avoid the deprecated TabActivity, and used this hack to allow me to incorporate Maps v1 in with the Fragments. It basically just masks an Activity as a Fragment.

    But then switched to TabActivity further down the track for simplicity / it was better suited for the whole app. But now obviously this 2x Maps v2 fragment problem has become an issue..

    So I have reverted back to "Tabs with Fragments" and just have the "hack setup" as mentioned above for each tab, which allows to have an Activity for each tab, AND having more than one Maps v2 displaying for each Tab. I haven't gone into too much depth with it, but it seems to be doing the job atm, with having just thrown some code together to test it out..

    Don't know if you're still having an issue with this / this obviously isn't the most correct solution, but just thought I'd share my two cents incase you still needed it.

    Cheers.

    0 讨论(0)
  • 2020-12-28 09:34

    We are having the exact same problem. I suspect this is caused by the fact that the new maps uses OpenGL - possibly android cant deal with having two OpenGL widgets in the view hierarchy at the same time even though one is hidden.

    The only way we worked around this was to actually remove the mapview when leaving a tab, then construct a new one and add it back in when going back into the tab. This ensures that there are never two maps constructed at once.

    Nasty, but it worked.

    0 讨论(0)
提交回复
热议问题