NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

As per asked in here... I am trying to implement OSM MapView in fragments. I've seen people done this in onCreateView

return new MapView(getActivity(), 256);

However I am not sure how to change my implementation of an Activity into Fragments... right now my Activity codes are like this:

MapView myOpenMapView;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mResourceProxy = new DefaultResourceProxyImpl(getApplicationContext());
    setContentView(R.layout.offline_map_activity);
    myOpenMapView = (MapView) findViewById(R.id.openmapview);
    myOpenMapView.getTileProvider().clearTileCache();

    //.... code continues
}

But I'm not sure how to convert this part of the code when implemented in Fragments:

setContentView(R.layout.offline_map_activity);
myOpenMapView = (MapView) findViewById(R.id.openmapview);

How do I instantiate the MapView object properly and return it in the onCreateView method?

asked 20 Feb '13, 14:56

lyk's gravatar image

lyk
41446
accept rate: 0%

edited 21 Feb '13, 00:25

aseerel4c26's gravatar image

aseerel4c26 ♦
32.6k18248554

hmm, this site is not really about coding with some specific toolkit... However, please link your post here also in stackoverflow to mitigate the bad effects of crossposting.

(21 Feb '13, 00:31) aseerel4c26 ♦

I already hyperlinked the stackoverflow question under the word "here". Oh, is this forum not about openstreetmap/OSMDroid? If that's the case where can I ask about implementing fragments with OSMDroid?

(21 Feb '13, 03:31) lyk

@lyk: I saw the "here". I mean that it would be good to insert a link into your question at stackoverflow.

A forum or a mailing list (e.g. dev?) are probably better suited - but you may get an answer here, too. Wait a day or two.

(21 Feb '13, 08:27) aseerel4c26 ♦

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×47
×1
×1

question asked: 20 Feb '13, 14:56

question was seen: 5,163 times

last updated: 21 Feb '13, 08:27

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum