当我创建使用谷歌地图应用程序接口v2的项目时,我有这个问题。
getFragmentManager().findFragmentById(R.id.map)) GoogleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map))());
上面说我需要将minSDK设置为最低11,但我也想在安卓minSDK 8 (2.3.3)的设备上使用这个应用程序。有什么想法吗?或者简单地说:如何设置谷歌地图应用程序接口v2,使其与minSDK 8设备兼容。
谢谢
发布于 2013-04-24 23:11:46
使用FragmentActivity中的SupportMapFragment,而不是Activity中的MapFragment。要在早于API11的设备上使用片段,您需要使用安卓支持包的片段的后端口( FragmentActivity就来自于此)。
发布于 2013-04-24 23:34:32
http://android-er.blogspot.de/2012/12/using-supportmapfragment.html -小示例
<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>和:
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);
}
}发布于 2013-07-25 23:36:19
Fragment fragment = getSupportFragmentManager().findFragmentById(
R.id.map);
SupportMapFragment mapFragment = (SupportMapFragment) fragment;
GoogleMap mMap = mapFragment.getMap();https://stackoverflow.com/questions/16195631
复制相似问题