O'Reilly logo

Mastering Android Application Development by Antonio Pachón Ruiz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding the map

Now that our application is configured for us to use map services, we can begin discussing how to add a visual map to our application. For the map, we will create another Fragment, which will be loaded on the second page of ViewPager.

There are two methods to display Google Map; either a MapFragment or a MapView object can represent it.

Adding the fragment

Create a new Java class within our fragments directory with the name MyMapFragment. The class should extend the Fragment type. Then, override the OnCreateView method and let it return the inflated view of fragment_my_map:

package com.packtpub.masteringandroidapp.fragments; import … /** * Created by Unathi on 7/29/2015. */ public class MyMapFragment extends Fragment { @Nullable @Override ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required