2010-05-12 5 views
1

J'essaie d'exécuter l'exemple Android MapView, et je reçois une erreur "Impossible à diffuser depuis View to MapView" dans Eclipse.Android: Je ne peux pas diffuser de Afficher à MapView

Ma mise en page est la suivante

<?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="0jwi0saLYCPGfO-t7glg5bQoBz7jVKWCcgyQWQA" 
/> 

<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> 

et le code d'activité est

package org.gaz.mapapp; 

import android.os.Bundle; 
import android.view.View; 
import android.widget.LinearLayout; 
import android.widget.ZoomControls; 

import com.google.android.maps.*; 

public class MapView extends MapActivity { 

LinearLayout linearLayout; 
MapView mapView; 
ZoomControls mZoom; 

public void onCreate(Bundle savedInstance) { 
    linearLayout = (LinearLayout) findViewById(R.id.mainlayout); 
    mapView = (MapView) findViewById(R.id.mapview); 
    mZoom = (ZoomControls) mapView.getZoomControls();  
} 

@Override 
protected boolean isRouteDisplayed() { 
    // TODO Auto-generated method stub 
    return false; 
} 
} 

L'erreur est causée par la ligne

mapView = (MapView) findViewById(R.id.mapview); 

Quelqu'un peut-il offrir une suggestion à un réparer?

Cheers, Gaz.

Répondre

8

Cela vient probablement du fait que vous nommiez votre propre classe MapView. Essayez de spécifier la classe complète com.google.android.maps.MapView pour la distinguer de la vôtre org.gaz.mapapp.MapView.

+0

Je ne peux pas croire que j'ai négligé cela! Merci Frank! – Gaz

Questions connexes