レイアウトXMLファイルからリソースを取得しようとしsetText()
ています。TextView
ユーザーがGoogleマップのマーカーをクリックしたとき。これは私がonTap()
マーカーのために書いたコードです。
追加しないまでTextView
、私のコードは正常に機能します。マーカーをクリックするとダイアログが表示され、すべてが機能します。
これらの行をに追加するonTap()
と、アプリケーションを実行してマーカーをクリックすると、と表示されなくなりますUnfortunately map has stopped
。
LogCatエラーメッセージが表示されます:
入力イベントのディスパッチ中にエラーが発生しました
OverlayItemクラスを拡張するクラスCustomOverlayItemを作成しました。Tv_descriptionTextView
は、レイアウトファイルcutom_dialog.xmlの一部です。
ユーザーがマーカーをクリックしたときに、実行時に動的に呼び出すsetText()
にはどうすればよいですか?TextView
@Override
protected boolean onTap(int index) {
Dialog dialog = new Dialog(context, android.R.style.Theme_Dialog);
TextView tv_description = new TextView(context);
tv_description = (TextView) dialog.findViewById(R.id.tv2_description);
tv_description.setText("checking");
dialog.setContentView(R.layout.custom_dialog);
dialog.show();
return true;
}
logcatの出力は次のとおりです。
07-31 11:59:16.271: E/Trace(2143): error opening trace file: No such file or directory (2)
07-31 11:59:17.741: E/ZoomButtonsController(2143): Cannot make the zoom controller visible if the owner view is not attached to a window.
07-31 11:59:18.151: E/MapActivity(2143): Couldn't get connection factory client
07-31 11:59:28.531: E/InputEventReceiver(2143): Exception dispatching input event.
07-31 11:59:28.541: E/MessageQueue-JNI(2143): Exception in MessageQueue callback: handleReceiveCallback
07-31 11:59:28.591: E/MessageQueue-JNI(2143): java.lang.NullPointerException
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.incubers.map.Markers.onTap(Markers.java:41)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:453)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.google.android.maps.MapView$1.onSingleTapUp(MapView.java:356)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:533)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.View.dispatchTouchEvent(View.java:7127)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2170)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1905)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1925)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1379)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.app.Activity.dispatchTouchEvent(Activity.java:2396)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1873)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.View.dispatchPointerEvent(View.java:7307)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3172)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3117)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4153)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4132)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4224)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.os.MessageQueue.nativePollOnce(Native Method)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.os.MessageQueue.next(MessageQueue.java:125)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.os.Looper.loop(Looper.java:124)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at java.lang.reflect.Method.invoke(Method.java:511)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-31 11:59:28.591: E/MessageQueue-JNI(2143): at dalvik.system.NativeStart.main(Native Method)
07-31 11:59:28.681: E/AndroidRuntime(2143): FATAL EXCEPTION: main
07-31 11:59:28.681: E/AndroidRuntime(2143): java.lang.NullPointerException
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.incubers.map.Markers.onTap(Markers.java:41)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:453)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.google.android.maps.MapView$1.onSingleTapUp(MapView.java:356)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:533)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.View.dispatchTouchEvent(View.java:7127)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2170)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1905)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2176)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1919)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1925)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1379)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.app.Activity.dispatchTouchEvent(Activity.java:2396)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1873)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.View.dispatchPointerEvent(View.java:7307)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3172)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3117)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4153)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4132)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4224)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.os.MessageQueue.nativePollOnce(Native Method)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.os.MessageQueue.next(MessageQueue.java:125)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.os.Looper.loop(Looper.java:124)
07-31 11:59:28.681: E/AndroidRuntime(2143): at android.app.ActivityThread.main(ActivityThread.java:4745)
07-31 11:59:28.681: E/AndroidRuntime(2143): at java.lang.reflect.Method.invokeNative(Native Method)
07-31 11:59:28.681: E/AndroidRuntime(2143): at java.lang.reflect.Method.invoke(Method.java:511)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
07-31 11:59:28.681: E/AndroidRuntime(2143): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
07-31 11:59:28.681: E/AndroidRuntime(2143): at dalvik.system.NativeStart.main(Native Method)