0

有没有办法在片段中实现 mapview 版本 1?我试过这样的:

主要活动:

public class MainActivity extends FragmentActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);                

    }    

然后,我想要 2 个片段。一个有地图视图,第二个将有一个文本视图,其中将显示位置。

我无法实现第一个片段。我不知道如何实现地图。我的意思是,要让地图视图工作,它需要“扩展 MapActivity”,但我需要“扩展片段”。

另外,在 main.xml 中怎么做?我试过:

 <fragment 
        class="com.google.android.maps.MapView"
        android:name="com.example.....MapClass"  //is this right?but it is necessary for fragment?
        android:id="@+id/fragment1"
        android:layout_weight="1"
        android:layout_width="0px"
        android:layout_height="match_parent"
        android:apiKey="mykey" />
    <fragment 
        class="com.example...getloclass"
        android:id="@+id/fragment2"
        android:layout_weight="1"
        android:layout_width="0px"
        android:layout_height="match_parent" />
4

1 回答 1

0

从这里https://developers.google.com/maps/documentation/android/v1/hello-mapview,您可以看到

自 2012 年 12 月 3 日起正式弃用 Google Maps Android API 版本 1

所以你不应该再使用MapView了。我建议你改用 a MapFragment。在此处查看优秀的文档:https ://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/MapFragment

于 2013-04-07T11:28:08.207 回答