title: Button to Map Android App
body: <p>I'm obviously new to app development but basically what I want to do is make a simple app that has a button called 'View Map' that, when pressed, will open up Google maps.</p>
  
  <p>So far, I've coded an app with the 'View Map' button that simply returns some text below the button when pressed, which looks like this. </p>
  
  <p><img src="https://i.stack.imgur.com/V2MsW.png" alt="enter image description here"></p>
  
  <p>I have also made another app which uses the Google Developers' <a href="https://developers.google.com/maps/documentation/android/hello-mapview" rel="nofollow noreferrer">tutorial</a> to display a Google map when the app is opened.</p>
  
  <p>My problem arises when I try to combine the two apps together. Instead of having it display just the button alone when opened, it displays both the button and the map in the home screen which looks like so: </p>
  
  <p><img src="https://i.stack.imgur.com/Hun61.png" alt="enter image description here"></p>
  
  <p>and does nothing when the button is pressed.</p>
  
  <p>What I've tried to do is use an OnClickListener that loads the map when the button is pressed, but that clearly ain't working. I assume it has something really basic to do with my activity_main class but I need help sorting it out so that the map isn't created immediately when the app is loaded.</p>
  
  <p>My activity_main class looks like this: </p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent" &gt;
  
  &lt;com.google.android.maps.MapView
      android:id="@+id/mapView"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:apiKey="**My Key**"
      android:clickable="true"
      android:enabled="true" /&gt;
  
  &lt;Button
      android:id="@+id/buttonMap"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:text="View Map" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And my MainActivity class looks like this:</p>
  
  <pre><code>public class MainActivity extends MapActivity {
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          Button buttonMap = (Button) findViewById(R.id.buttonMap);
          buttonMap.setOnClickListener(mapListener);
      }
  
      private OnClickListener mapListener = new OnClickListener() {
          public void onClick(View v) {
              MapView mapView = (MapView) findViewById(R.id.mapView);
              mapView.setBuiltInZoomControls(true);
          }
     };
  
      @Override
      protected boolean isRouteDisplayed() {
          return false;
      }
  }
  </code></pre>
  
  <p>Any help is appreciated, cheers.</p>