Android的谷歌地图不里TabHost装载 [英] android Google Map doesn't load inside TabHost

查看:111
本文介绍了Android的谷歌地图不里TabHost装载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

后吓坏了,并唉阻挠想我API密钥是错误的几天里,我发现我的图形页面将在我的应用程序加载只在屏幕的主要内容。

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 screen.

每当我试图把它连接到一个TabHost或试图通过 getDecorView加载它()里面的已经存在视图,地图不加载和我得到的只是一个空白的地图。

Every time I'm trying to attach it to a TabHost or trying to load it through getDecorView() inside an already exist view, the map doesn't load and i get a blank map only.

这是非常重要的,我在TabHost使用。

it is really important for me to use in a TabHost.

是否有人有一个想法如何解决它或它为什么发生?

Does someone have an idea how to fix it or why it's happening ?

推荐答案

这,到底,主持一个图形页面必须的是活动一个 MapActivity ,至少在地图的当前版本附加为Android。

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.

例如,有些人尝试使用 TabActivity ,并使用活动选项卡的内容。这就是正式去$ P $现在pcated,恕我直言从未在首位一个特别好的模式。当涉及到地图,即使你尝试加载到卡的活动是 MapActivity ,这其实并不重要 - 活动的包含标签必须有一个 MapActivity 。常见的解决方法是使用 TabHost TabWidget MapActivity 。虽然这确实需要调用设置() TabHost ,而你失去了一些辅助方法,它会过去此问题

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.

这篇关于Android的谷歌地图不里TabHost装载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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