5
Zdaję sobie sprawę, że istnieje jakiś patch do fragmentów dotyczących Mapsforge tutaj: https://code.google.com/p/mapsforge/issues/detail?id=177 .Jednak nie jestem do końca pewien, jak go używać.Fragment Wsparcie Mapsforge
To właśnie zostały wdrożone do tej pory:
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;
}
}
To jest mój plik 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>
Dostaję taki błąd:
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)
Co jest źle z tym?