Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8932273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:17:49+00:00 2026-06-15T09:17:49+00:00

I am developing one application in whcih i Have integerate Sherlock Actionbar with Fragment.there

  • 0

I am developing one application in whcih i Have integerate Sherlock Actionbar with Fragment.there are two tab, First is Map and Second is For Listing. For First Map tab I want to Put MapsForge opensource library base Map in this First Tab.I have got Example for MapsForge with Fragment from GIt from Hereand i have tried to implement it.but it getting me Error of NoSaveStateFramelayout

Error ::

12-03 18:48:49.210: E/AndroidRuntime(2779): FATAL EXCEPTION: main
12-03 18:48:49.210: E/AndroidRuntime(2779): java.lang.ClassCastException: android.support.v4.app.NoSaveStateFrameLayout cannot be cast to com.jakewharton.android.mapsforge_fragment.MapView
12-03 18:48:49.210: E/AndroidRuntime(2779):     at in.wptrafficanalyzer.actionbarsherlocknavtab.MapFragment.getView(MapFragment.java:32)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at in.wptrafficanalyzer.actionbarsherlocknavtab.MapFragment.getView(MapFragment.java:1)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.support.v4.app.FragmentPagerAdapter.isViewFromObject(FragmentPagerAdapter.java:147)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.support.v4.view.ViewPager.infoForChild(ViewPager.java:1258)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.support.v4.view.ViewPager.populate(ViewPager.java:1031)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.support.v4.view.ViewPager.populate(ViewPager.java:881)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1366)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.View.measure(View.java:12775)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:594)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:376)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.View.measure(View.java:12775)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4709)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.View.measure(View.java:12775)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:822)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:563)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.View.measure(View.java:12775)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4709)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2240)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.View.measure(View.java:12775)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1117)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2505)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.os.Looper.loop(Looper.java:137)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at android.app.ActivityThread.main(ActivityThread.java:4514)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at java.lang.reflect.Method.invokeNative(Native Method)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at java.lang.reflect.Method.invoke(Method.java:511)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
12-03 18:48:49.210: E/AndroidRuntime(2779):     at dalvik.system.NativeStart.main(Native Method)

Code:

MapFragment :

package in.wptrafficanalyzer.actionbarsherlocknavtab;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.jakewharton.android.mapsforge_fragment.GeoPoint;
import com.jakewharton.android.mapsforge_fragment.MapView;
import com.jakewharton.android.mapsforge_fragment.MapViewMode;

public class MapFragment extends Fragment {
    private static final String KEY_LATITUDE_E6 = "MapFragment:LatitudeE6";
    private static final String KEY_LONGITUDE_E6 = "MapFragment:LongitudeE6";
    private static final String KEY_ZOOM_LEVEL = "MapFragment:ZoomLevel";
    private static final String KEY_MAP_FILE = Environment.getExternalStorageDirectory()+ "/great_britain.map";

    private final MapViewMode mMapViewMode;


    public MapFragment() {
        this(MapView.DEFAULT_MAP_VIEW_MODE);
    }

    public MapFragment(MapViewMode mapViewMode) {
        mMapViewMode = mapViewMode;
    }


    @Override
    public MapView getView() {
        return (MapView)super.getView();
    }

    @Override
    public MapView onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        MapView mapView = new MapView(getActivity(), mMapViewMode);
        if (savedInstanceState != null) 
        {
            final int latitude = savedInstanceState.getInt(KEY_LATITUDE_E6, Integer.MIN_VALUE);
            final int longitude = savedInstanceState.getInt(KEY_LONGITUDE_E6, Integer.MIN_VALUE);
            final byte zoom = savedInstanceState.getByte(KEY_ZOOM_LEVEL, Byte.MIN_VALUE);
            final String mapFile = savedInstanceState.getString(KEY_MAP_FILE);

            if ((mapFile != null) && !mapView.getMapViewMode().requiresInternetConnection()) {
                mapView.setMapFileFromParcel(mapFile);
            }

            if ((latitude != Integer.MIN_VALUE) && (longitude != Integer.MIN_VALUE) && (zoom != Byte.MIN_VALUE)) {
                mapView.setCenterAndZoom(new GeoPoint(latitude, longitude), zoom);
            }
        }

        return mapView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        MapView mapView = getView();
        if (mapView != null) {
            mapView.destroy();
            mapView = null;
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

        MapView mapView = getView();
        if (mapView.hasValidCenter()) {
            if (!mapView.getMapViewMode().requiresInternetConnection() && (mapView.getMapFile() != null)) {
                outState.putString(KEY_MAP_FILE, mapView.getMapFile());
            }

            GeoPoint center = mapView.getMapCenter();
            outState.putInt(KEY_LATITUDE_E6, center.getLatitudeE6());
            outState.putInt(KEY_LONGITUDE_E6, center.getLongitudeE6());
            outState.putByte(KEY_ZOOM_LEVEL, mapView.getZoomLevel());
        }
    }

}

Update ::

package in.wptrafficanalyzer.actionbarsherlocknavtab;
import android.os.Bundle;
import android.os.Environment;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.jakewharton.android.mapsforge_fragment.GeoPoint;
import com.jakewharton.android.mapsforge_fragment.MapView;
import com.jakewharton.android.mapsforge_fragment.MapViewMode;

public class MapFragment extends Fragment {
    private static final String KEY_LATITUDE_E6 = "MapFragment:LatitudeE6";
    private static final String KEY_LONGITUDE_E6 = "MapFragment:LongitudeE6";
    private static final String KEY_ZOOM_LEVEL = "MapFragment:ZoomLevel";
    private static final String KEY_MAP_FILE = Environment.getExternalStorageDirectory()+ "/great_britain.map";

    private final MapViewMode mMapViewMode;


    public MapFragment() {
        this(MapView.DEFAULT_MAP_VIEW_MODE);
    }

    public MapFragment(MapViewMode mapViewMode) {
        mMapViewMode = mapViewMode;
    }

    @Override
    public MapView getView() {
        NoSaveStateFrameLayout wrapper = (NoSaveStateFrameLayout)super.getView();
        return (MapView)((wrapper != null) ? wrapper.getChildAt(0) : null);
    }

    @Override
    public MapView onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        MapView mapView = new MapView(getActivity(), mMapViewMode);
        if (savedInstanceState != null) {
            final int latitude = savedInstanceState.getInt(KEY_LATITUDE_E6, Integer.MIN_VALUE);
            final int longitude = savedInstanceState.getInt(KEY_LONGITUDE_E6, Integer.MIN_VALUE);
            final byte zoom = savedInstanceState.getByte(KEY_ZOOM_LEVEL, Byte.MIN_VALUE);
            final String mapFile = savedInstanceState.getString(KEY_MAP_FILE);

            if ((mapFile != null) && !mapView.getMapViewMode().requiresInternetConnection()) {
                mapView.setMapFileFromParcel(mapFile);
            }

            if ((latitude != Integer.MIN_VALUE) && (longitude != Integer.MIN_VALUE) && (zoom != Byte.MIN_VALUE)) {
                mapView.setCenterAndZoom(new GeoPoint(latitude, longitude), zoom);
            }
        }

        return mapView;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        MapView mapView = getView();
        if (mapView != null) {
            mapView.destroy();
            mapView = null;
        }
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);

        MapView mapView = getView();
        if (mapView.hasValidCenter()) {
            if (!mapView.getMapViewMode().requiresInternetConnection() && (mapView.getMapFile() != null)) {
                outState.putString(KEY_MAP_FILE, mapView.getMapFile());
            }

            GeoPoint center = mapView.getMapCenter();
            outState.putInt(KEY_LATITUDE_E6, center.getLatitudeE6());
            outState.putInt(KEY_LONGITUDE_E6, center.getLongitudeE6());
            outState.putByte(KEY_ZOOM_LEVEL, mapView.getZoomLevel());
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:17:50+00:00Added an answer on June 15, 2026 at 9:17 am

    Based on the link you provided, is there a reason you went away from their getView() method?

    @Override
    public MapView getView() {
        NoSaveStateFrameLayout wrapper = (NoSaveStateFrameLayout)super.getView();
        return (MapView)((wrapper != null) ? wrapper.getChildAt(0) : null);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hai every one I am developing an windows application in which i have to
I am developing one application which need the following functionalities I have webserver. I
I am developing one application and in which i have to display a five
I am developing a web based application in which i have two hyperlinks in
I am developing an application in which i have Implement CustomListview with one icon,
I have been developing Android application which has 3 ListView and one ContextMenu for
I am developing one application in which I have set lots of text in
i am developing one application with iphone & Yii framework(PHP Server side), i have
I am developing an application which is having 2 servers. The first one is
I am developing one android application in which i have implemented the 10 ads

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.