Как решить Google Map View в Android? Когда я попробовал эту программу, я получил следующую ошибку - PullRequest
1 голос
/ 28 декабря 2011
SampleApplication.java

package com.example;  
    import android.app.Activity;
    import android.os.Bundle;

    public class SampleMapApplication extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);


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

    Main.Xml:
        <?xml version="1.0" encoding="utf-8"?>
       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello" />
    <com.google.android.maps.MapView
    android:id="@+id/mapView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:enabled="true"
    android:clickable="true"
    android:apiKey="0U7-rnRk3Os0sPZnZF9iejONnHMsGRLxU0JbrBg"/>
    </LinearLayout>

Файл манифеста:

                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
        </application>
     <uses-permission android:name="android.permission.INTERNET"/>
    </manifest>

Ошибка: вывод выглядит следующим образом

Source not found..
Thread [<1> main] (Suspended (exception RuntimeException))  
    ActivityThread.performLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1647    
    ActivityThread.handleLaunchActivity(ActivityThread$ActivityClientRecord, Intent) line: 1663 
    ActivityThread.access$1500(ActivityThread, ActivityThread$ActivityClientRecord, Intent) line: 117   
    ActivityThread$H.handleMessage(Message) line: 931   
    ActivityThread$H(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 123 
    ActivityThread.main(String[]) line: 3683    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 507  
    ZygoteInit$MethodAndArgsCaller.run() line: 839  
    ZygoteInit.main(String[]) line: 597 
    NativeStart.main(String[]) line: not available [native method]

1 Ответ

0 голосов
/ 28 декабря 2011

Сначала создайте новый проект Android и выберите целевое устройство Android API Google не только Android API.

main.xml: -

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
      <com.google.android.maps.MapView android:layout_marginTop="10dip"
        android:id="@+id/mapView" android:layout_width="fill_parent"
        android:layout_height="fill_parent" android:enabled="true"
        android:clickable="true"
        android:apiKey="02PaBI0a1TZrB-nwZwXYW1u82YKJR0QLD_xDHpA" />
</RelativeLayout>

Файл Java: -

public class Display_GoogleMap_Activity extends MapActivity {

    @Override
    protected void onCreate(Bundle icicle) {
        // TODO Auto-generated method stub
        super.onCreate(icicle);
        setContentView(R.layout.google_mapsscreen);
    }

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

Попробуй.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...