Mapsforge support for using SherlockFragments to support lower end OS

298 views
Skip to first unread message

Yukai Lin

unread,
Mar 21, 2013, 1:35:44 PM3/21/13
to mapsfo...@googlegroups.com
I am aware that there is some kind of patch for fragments for Mapsforge here: https://code.google.com/p/mapsforge/issues/detail?id=177 .However I'm not exactly sure how to use it. I've been asking around for help to no avail, and got rejected when I submitted it as an issue.

Also, I would prefer to use SherlockFragments as I need to support lower end OS, thus the solution in Issue #177 might not be as applicable in my situation. Would really appreciate it if there's someone out there that can enlighten me on what's going on with my codes, or if there's anyway I can implement SherlockFragment using the provided codes in Issue #177, I've been trying it for days and I can't even implement MapFragment class as there are so many errors when i placed the java file into my Eclipse project, as there were many missing methods for MapView even when I'm using version 0.3.1.

I've already managed to implement SherlockFragments for osmdroid library, and I thought the implementation should be very similar with mapsforge. However it doesn't seem to work when I coded it in the same way.

This is what I've implemented so far:

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("/offlineMap/singapore.map"));

               return view;
        }

}

This is my xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    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>

I'm getting this error:

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 #11: Error inflating class org.mapsforge.android.maps.MapView

Michele Mondelli

unread,
Apr 2, 2013, 12:00:38 PM4/2/13
to mapsfo...@googlegroups.com
Hi.

Are you still looking for a solution?
After a couple of days I've been able to use MapFragment together with ActionBarSherlock.
You can found the modified code here: https://code.google.com/r/mithenksml-mapsforge/ .

Hope this helps!

Regards,
 Mithenks

Christian Sasig

unread,
Jun 5, 2013, 4:05:12 PM6/5/13
to mapsfo...@googlegroups.com

Hi,

I do not find the MapFragment.java file in the project. can you help me please?

Michele Mondelli

unread,
Jun 12, 2013, 11:30:17 AM6/12/13
to mapsfo...@googlegroups.com
You can checkout my clone (of 0.3.0 branch) and compile it.
Reply all
Reply to author
Forward
0 new messages