gpt4 book ai didi

android - Mapsforge 的 fragment 支持

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:16:46 28 4
gpt4 key购买 nike

我知道这里有一些针对 Mapsforge fragment 的补丁:https://code.google.com/p/mapsforge/issues/detail?id=177 .但是我不确定如何使用它。

这是我到目前为止实现的:

public class TOfflineMapViewFragment  extends SherlockFragment{

MapView myOpenMapView;
//other codes here...

public View onCreateView(LayoutInflater inflator, ViewGroup container, Bundle savedInstanceState) {

view = inflator.inflate(R.layout.offline_map_activity, container, false);

myOpenMapView = (MapView) view.findViewById(R.id.openmapview);
myOpenMapView.setMapFile(new File(Environment.getExternalStorageDirectory().toString() +
"/offlineMap/singapore.map");

return view;
}

}

这是我的 xml 文件:

<LinearLayout 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"
android:orientation="vertical" >
<org.mapsforge.android.maps.MapView
android:id="@+id/openmapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>

我收到这个错误:

03-19 15:51:04.243: E/AndroidRuntime(10395): FATAL EXCEPTION: main

03-19 15:51:04.243: E/AndroidRuntime(10395): android.view.InflateException: Binary XML file line #6: Error inflating class org.mapsforge.android.maps.MapView
03-19 15:51:04.243: E/AndroidRuntime(10395): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
03-19 15:51:04.243: E/AndroidRuntime(10395): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
03-19 15:51:04.243: E/AndroidRuntime(10395): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
03-19 15:51:04.243: E/AndroidRuntime(10395): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-19 15:51:04.243: E/AndroidRuntime(10395): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-19 15:51:04.243: E/AndroidRuntime(10395): at com.fragments.TOfflineMapViewFragment.onCreateView(TOfflineMapViewFragment.java:76)

这是怎么回事?

最佳答案

添加

AndroidGraphicFactory.createInstance(getActivity().getApplication());

在重写的 onCreate() 中为我工作

关于android - Mapsforge 的 fragment 支持,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15494210/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com