2012-01-27 9 views
1

小さなコントロールでズームコントロールを使用しようとしています。下のコードを起動すると、エミュレータでアプリがクラッシュする(Android 2.3.3 Google APIを使用)。私がコメントアウトしたとき:セット内蔵ズームコントロールがエミュレータアプリケーションをクラッシュします

myMapView.setBuiltInZoomControls(false); 

私は地図をすべてズームアウトして表示します。私が間違っていることに関するアイデアは?

ありがとうございます!

MainActivity.java

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

    myMapView = (MapView) findViewById(R.id.mymapView); 
    myMapView.setBuiltInZoomControls(true); 
} 



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

AndroidManifest

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
package="net.learn2develop.LBS" 
android:versionCode="1" 
android:versionName="1.0" > 




<application 
    android:icon="@drawable/ic_launcher" 
    android:label="@string/app_name" > 
<uses-library android:name="com.google.android.maps"/> 
    <activity 
     android:label="@string/app_name" 
     android:name=".MainActivity" 
     > 
     <intent-filter > 
      <action android:name="android.intent.action.MAIN" /> 

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

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

<com.google.android.maps.MapView 
    android.id="@+id/mymapView" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:enabled="true" 
    android:clickable="true" 
    android:apiKey="KEY_HERE"/> 
</LinearLayout> 
+0

私たちに推測させてはいけません - 質問に明白な答えがあると思われるスタックトレースを追加してください。 – BitBank

答えて

0

私は新しいプロジェクトにコードを引っ張られ、問題を発見しました。

このライン:

android.id="@+id/mymapView" 

android:id="@+id/mymapView" 

お知らせコロン対ドットする必要があります!

これにより、findViewByIdがnullを返し、myMapView.setBuiltInZoomControls()がsegfaultingしていました。

関連する問題