LOGCAT错误阻止我打开MAP活动并停止 工作。
2019-07-03 17:12:01.642 29273-29273/com.example.ess E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.ess, PID: 29273
java.lang.IllegalStateException: Could not find method map(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatImageView with id 'imageView5'
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:424)
at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:381)
at android.view.View.performClick(View.java:6993)
at android.view.View$PerformClick.run(View.java:26512)
at android.os.Handler.handleCallback(Handler.java:790)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:7025)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1408)
答案 0 :(得分:0)
您在布局xml中应用了android:onClick=map
属性。
如您在日志中所见,它位于ImageView android.support.v7.widget.AppCompatImageView
中,带有android:id=@+id/imageView5
所以:
android:onClick="map"
,并使用OnClickListener
public void map(View v) {}