public class HelloMapView extends MapActivity
{
        LinearLayout linearLayout;
        MapView mapView;
        ZoomControls mZoom;
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
                super.onCreate(savedInstanceState);

 setContentView(R.layout.main);

                linearLayout = (LinearLayout) findViewById
(R.id.zoomview);
                mapView = (MapView) findViewById(R.id.mapview);
                mZoom = (ZoomControls) mapView.getZoomControls();
                linearLayout.addView(mZoom);
                       }


        @Override
        protected boolean isRouteDisplayed() {
                return false;
        }



}


On Jun 5, 3:24 am, Daniel <[email protected]> wrote:
> I'm following this tutorial 
> here:http://developer.android.com/guide/tutorials/views/hello-mapview.html
>
> and am on point 11
>
> Here's the res/layout/main.xml:
>
> <?xml version="1.0" encoding="utf-8"?>
> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/
> android"
>   android:id="@+id/mainlayout"
>   android:orientation="vertical"
>   android:layout_width="fill_parent"
>   android:layout_height="fill_parent" >
>
>   <com.google.android.maps.MapView
>     android:id="@+id/mapview"
>     android:layout_width="fill_parent"
>     android:layout_height="fill_parent"
>     android:clickable="true"
>     android:apiKey="hidden"
>   />
>
>   <LinearLayout
>     android:id="@+id/zoomview"
>     android:layout_width="wrap_content"
>     android:layout_height="wrap_content"
>     android:layout_alignBottom="@id/mapview"
>     android:layout_centerHorizontal="true"
>   />
>
> </RelativeLayout>
>
> Here's the code:
>
> package com.example.hellomapview;
>
> import android.app.Activity;
> import android.os.Bundle;
> import com.google.android.maps.*;
> import android.widget.LinearLayout;
> import android.widget.ZoomControls;
>
> public class HelloMapView extends MapActivity
> {
>         LinearLayout linearLayout;
>         MapView mapView;
>         ZoomControls mZoom;
>         /** Called when the activity is first created. */
>         @Override
>         public void onCreate(Bundle savedInstanceState)
>         {
>                 super.onCreate(savedInstanceState);
>                 linearLayout = (LinearLayout)findViewById
> (R.id.zoomview);
>                 mapView = (MapView)findViewById(R.id.mapview);
>                 mZoom = (ZoomControls) mapView.getZoomControls();
>                 linearLayout.addView(mZoom);
>                 setContentView(R.layout.main);
>         }
>
>         @Override
>         protected boolean isRouteDisplayed() {
>                 return false;
>         }
>
> }
>
> Here's the manifest:
>
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android";
>       package="com.example.hellomapview"
>       android:versionCode="1"
>       android:versionName="1.0">
>     <uses-permission android:name="android.permission.INTERNET" />
>     <application android:label="@string/app_name">
>         <uses-library android:name="com.google.android.maps" />
>         <activity android:name=".HelloMapView"
>                   android:label="@string/app_name">
>             <intent-filter>
>                 <action android:name="android.intent.action.MAIN" />
>                 <category
> android:name="android.intent.category.LAUNCHER" />
>             </intent-filter>
>         </activity>
>     </application>
> </manifest>
>
> I've built both this project and the avd I'm loading it to as target
> 3's, meaning they should have maps capability, and have acquired a
> proper Maps apiKey (which I've hidden in this post)
>
> If I back up to step 6 in the tutorial, everything works, which means
> the map loads and I can pan around, but when I try to reference the
> MapView in the xml with this line:
>                 mapView = (MapView)findViewById(R.id.mapview);
>
> the view returned is null.
>
> Here's the ant debug output:
>
> $ ant debug
> Buildfile: build.xml
>     [setup] Project Target: Google APIs
>     [setup] Vendor: Google Inc.
>     [setup] Platform Version: 1.5
>     [setup] API level: 3
>
> dirs:
>      [echo] Creating output directories if needed...
>
> resource-src:
>      [echo] Generating R.java / Manifest.java from the resources...
>
> aidl:
>      [echo] Compiling aidl files into Java classes...
>
> compile:
>     [javac] Compiling 2 source files to /home/doubleagent/Programming/
> ANDROID/HelloMapView/bin/classes
>     [javac] Note: /home/doubleagent/Programming/ANDROID/HelloMapView/
> src/com/example/hellomapview/HelloMapView.java uses or overrides a
> deprecated API.
>     [javac] Note: Recompile with -Xlint:deprecation for details.
>
> dex:
>      [echo] Converting compiled files and external libraries into bin/
> classes.dex...
>
> package-resources:
>      [echo] Packaging resources
>  [aaptexec] Creating full resource package...
>
> debug:
> [apkbuilder] Creating HelloMapView-debug.apk and signing it with a
> debug key...
> [apkbuilder] Using keystore: /home/doubleagent/.android/debug.keystore
>
> BUILD SUCCESSFUL
> Total time: 2 seconds
>
> Any idea what I could be doing wrong?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to