Displaying an osmdroid map works the same way, regardless of whether you use it inside an Activity or Fragment. Just put it in your layout file and inflate it in your fragment, or create a MapView directly in the onCreateView method of your fragment.
To create a fragment containing the default map, you can do something like this:
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return new MapView(getActivity(), 256); }
in your fragment class.
If you want to use the layout that your MapView contains, you can do something similar in your fragment:
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.offline_map_activity, null); myOpenMapView = v.findViewById(R.id.openmapview); return v; }
source share