android Google Map doesn't load inside TabHost

后端 未结 1 1659
借酒劲吻你
借酒劲吻你 2020-12-22 10:12

after few days of freaking out and ugh frustrate thinking my API key is wrong, i found out that my MapView will load in my application only when its the main content of the

1条回答
  •  礼貌的吻别
    2020-12-22 10:21

    The activity that, in the end, hosts a MapView must be a MapActivity, at least in the current incarnation of the Maps add-on for Android.

    This can cause confusion, or outright problems, where you are trying to have the activity be something else.

    For example, some people try to use a TabActivity, and use activities as the contents of tabs. That is officially deprecated now, and IMHO was never an especially good model in the first place. When it comes to maps, even if the activity you try loading into the tab is a MapActivity, that does not really matter -- the activity containing the tabs must be a MapActivity. The common workaround is to use TabHost and TabWidget in a MapActivity. While this does require a call to setup() on the TabHost, and you lose some helper methods, it gets past this problem.

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