0

以下のコードをAndroid での Google マップの使用 から使用して、googlemaps api を使用してアプリを作成しますが、例外エラーが発生します。

mapView = (MapView) findViewById(R.id.mapView);
LinearLayout zoomLayout = (LinearLayout) findViewById(R.id.zoom);
View zoomView = mapView.getZoomControls();
zoomLayout.removeAllViews();
zoomLayout.addView(zoomView, new LinearLayout.LayoutParams(
        android.widget.LinearLayout.LayoutParams.WRAP_CONTENT,
        android.widget.LinearLayout.LayoutParams.WRAP_CONTENT));
mapView.displayZoomControls(true);

mapView は でプライベートとして定義されていpublic class MapsActivity extends MapActivityます。EclipseでView zoomView = mapView.getZoomControls();この警告を表示します。タイプ MapView のメソッド getZoomControls() は廃止されました logCat は次のとおりです。

10-08 15:27:47.606: D/dalvikvm(428): GC_FOR_MALLOC freed 4774 objects / 299864 bytes in 88ms
10-08 15:27:47.826: D/dalvikvm(428): GC_FOR_MALLOC freed 9901 objects / 603608 bytes in 68ms
10-08 15:27:48.016: D/dalvikvm(428): GC_FOR_MALLOC freed 4954 objects / 323936 bytes in 67ms
10-08 15:27:48.226: D/dalvikvm(428): GC_FOR_MALLOC freed 6199 objects / 378152 bytes in 67ms
10-08 15:27:48.466: D/dalvikvm(428): GC_FOR_MALLOC freed 8551 objects / 651664 bytes in 63ms
10-08 15:27:48.676: D/dalvikvm(428): GC_FOR_MALLOC freed 6074 objects / 370080 bytes in 60ms
10-08 15:27:48.716: D/AndroidRuntime(428): Shutting down VM
10-08 15:27:48.716: W/dalvikvm(428): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-08 15:27:48.736: E/AndroidRuntime(428): FATAL EXCEPTION: main
10-08 15:27:48.736: E/AndroidRuntime(428): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.avizhegroup.googlemaps/com.avizhegroup.googlemaps.MapsActivity}: android.view.InflateException: Binary XML file line #14: Error inflating class linearLayout
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.os.Looper.loop(Looper.java:123)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.ActivityThread.main(ActivityThread.java:4627)
10-08 15:27:48.736: E/AndroidRuntime(428):  at java.lang.reflect.Method.invokeNative(Native Method)
10-08 15:27:48.736: E/AndroidRuntime(428):  at java.lang.reflect.Method.invoke(Method.java:521)
10-08 15:27:48.736: E/AndroidRuntime(428):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-08 15:27:48.736: E/AndroidRuntime(428):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-08 15:27:48.736: E/AndroidRuntime(428):  at dalvik.system.NativeStart.main(Native Method)
10-08 15:27:48.736: E/AndroidRuntime(428): Caused by: android.view.InflateException: Binary XML file line #14: Error inflating class linearLayout
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-08 15:27:48.736: E/AndroidRuntime(428):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.Activity.setContentView(Activity.java:1647)
10-08 15:27:48.736: E/AndroidRuntime(428):  at com.avizhegroup.googlemaps.MapsActivity.onCreate(MapsActivity.java:33)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-08 15:27:48.736: E/AndroidRuntime(428):  ... 11 more
10-08 15:27:48.736: E/AndroidRuntime(428): Caused by: java.lang.ClassNotFoundException: android.view.linearLayout in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.avizhegroup.googlemaps-1.apk]
10-08 15:27:48.736: E/AndroidRuntime(428):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
10-08 15:27:48.736: E/AndroidRuntime(428):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
10-08 15:27:48.736: E/AndroidRuntime(428):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.createView(LayoutInflater.java:466)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
10-08 15:27:48.736: E/AndroidRuntime(428):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
10-08 15:27:48.736: E/AndroidRuntime(428):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
10-08 15:27:48.736: E/AndroidRuntime(428):  ... 20 more
10-08 15:27:50.956: I/Process(428): Sending signal. PID: 428 SIG: 9

ズームボタンマップの実行と表示を正しくカスタマイズする前に。どうすればこれを修正できますか? ありがとう。

4

1 に答える 1

0
map.setBuiltInZoomControls(true);

それを試してみてください。

于 2012-10-08T12:07:42.890 に答える