首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >minSDK低于11的安卓设备上的谷歌地图v2

minSDK低于11的安卓设备上的谷歌地图v2
EN

Stack Overflow用户
提问于 2013-04-24 23:10:32
回答 3查看 4.1K关注 0票数 1

当我创建使用谷歌地图应用程序接口v2的项目时,我有这个问题。

getFragmentManager().findFragmentById(R.id.map)) GoogleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))());

上面说我需要将minSDK设置为最低11,但我也想在安卓minSDK 8 (2.3.3)的设备上使用这个应用程序。有什么想法吗?或者简单地说:如何设置谷歌地图应用程序接口v2,使其与minSDK 8设备兼容。

谢谢

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2013-04-24 23:11:46

使用FragmentActivity中的SupportMapFragment,而不是Activity中的MapFragment。要在早于API11的设备上使用片段,您需要使用安卓支持包的片段的后端口( FragmentActivity就来自于此)。

票数 6
EN

Stack Overflow用户

发布于 2013-04-24 23:34:32

http://android-er.blogspot.de/2012/12/using-supportmapfragment.html -小示例

代码语言:javascript
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="@string/hello_world" />
    <fragment
        android:id="@+id/map"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        class="com.google.android.gms.maps.SupportMapFragment"/>

</RelativeLayout>

和:

代码语言:javascript
复制
package de.meinprospekt.android.ui;

import java.text.SimpleDateFormat;

public class MainActivity extends FragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

}
票数 2
EN

Stack Overflow用户

发布于 2013-07-25 23:36:19

代码语言:javascript
复制
    Fragment fragment = getSupportFragmentManager().findFragmentById(
            R.id.map);
    SupportMapFragment mapFragment = (SupportMapFragment) fragment;
    GoogleMap mMap = mapFragment.getMap();
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16195631

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档