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 8624873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:38:22+00:00 2026-06-12T07:38:22+00:00

I am adding a Map to a fragment with this code: public class MapFragment

  • 0

I am adding a Map to a fragment with this code:

public class MapFragment : Fragment
{
    private MapActivity map=null;
    public override Android.Views.View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
    {
        return new FrameLayout(Activity);
    }

    public override void OnActivityCreated(Bundle savedInstanceState)
    {
        base.OnActivityCreated(savedInstanceState);
        map = new MapView(Activity,"XXXXX-v0jt5Z-XXXXXX");
        //HOW TO ADD THE VIEW HERE???
    }
}

My question is, in Mono for Android how to I add the Map to the View.

Note: In Java I would write this:

((ViewGroup)getView()).addView(map);

Footnote: This example uses code from the Java MapFragment source code: https://github.com/commonsguy/cw-omnibus/blob/master/Maps/NooYawkFragments/src/com/commonsware/android/mapfrags/MapFragment.java

  • 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-12T07:38:23+00:00Added an answer on June 12, 2026 at 7:38 am

    Maps can not be added to Fragments as is, they need a hosting environment.

    Here’s the solution for a MapFragment:

    namespace BahaiResearch.com
    {
    public class MyMapFragment : Fragment
    {
        // FROM http://stackoverflow.com/questions/5109336/mapview-in-a-fragment-honeycomb
        private static  String KEY_STATE_BUNDLE = "localActivityManagerState";
    
        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
    
            Bundle state = null;
            if (savedInstanceState != null) {
                state = savedInstanceState.GetBundle(KEY_STATE_BUNDLE);
            }
            mLocalActivityManager = new LocalActivityManager(Activity, true);
            mLocalActivityManager.DispatchCreate(state);
        }
    
        public override Android.Views.View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            //This is where you specify you activity class
            Intent i = new Intent(Activity, typeof(SteamLocationMapActivity)); 
            Window w = mLocalActivityManager.StartActivity("tag", i); 
            View currentView=w.DecorView; 
            currentView.Visibility = ViewStates.Visible; 
            currentView.FocusableInTouchMode = true; 
            ((ViewGroup) currentView).DescendantFocusability = DescendantFocusability.AfterDescendants;
            return currentView;
        }
    
        private LocalActivityManager mLocalActivityManager;
        protected LocalActivityManager GetLocalActivityManager() {
            return mLocalActivityManager;
        }   
    
    
        public override void OnSaveInstanceState(Bundle outState)
        {
            base.OnSaveInstanceState(outState);
            outState.PutBundle(KEY_STATE_BUNDLE,mLocalActivityManager.SaveInstanceState());
        }
    
        public override void OnResume()
        {
            base.OnResume();
            mLocalActivityManager.DispatchResume();
    
        }
    
        public override void OnPause()
        {
            base.OnPause();
            mLocalActivityManager.DispatchPause(Activity.IsFinishing);
        }
    
        public override void OnStop()
        {
            base.OnStop();
            mLocalActivityManager.DispatchStop();
        }
    }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my app I'm adding and removing annotations to my map view, but actually
I'm getting the following warning when adding overlays to my map view: Sending 'MKOverlayView
I wrote something like this: class Storage { public: Storage(); QString key() const; int
Let's say I have a model that looks like this: public class Blog {
I'm adding markers to my Google Map like this: function createMarker(location, info) { var
When I am adding a Google Map marker using this tutorial, I am able
I have a map like this: private Map<String, List<List<String>>> someMap; private List<List<String>> someList1; private
When adding a google map view (I extended a MapView, used the xml editor
Im having problem's adding map markers to gmaps using jquery. Here is my code
I'm having problems with adding lines to the map in my android project. Basically,

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.