我设计了一个注册表单,数据将作为Json对象发送到api。我收到这些错误,无法解决它们
错误讯息:
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: FATAL EXCEPTION: main
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: Process: com.example.android.bet, PID: 2608
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: java.lang.IllegalStateException: Could not find method signUpp(View) in a parent or ancestor Context for android:onClick attribute defined on view class android.support.v7.widget.AppCompatButton with id 'sign_up'
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:307)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:266)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.view.View.performClick(View.java:5198)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.view.View$PerformClick.run(View.java:21147)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:148)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
04-08 11:37:39.542 2608-2608/? E/AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-08 11:37:39.544 1300-1395/? W/ActivityManager: Force finishing activity com.example.android.bet/.SignUp
04-08 11:37:39.617 1300-1348/? I/OpenGLRenderer: Initialized EGL, version 1.4
04-08 11:37:39.628 1300-1348/? W/EGL_emulation: eglSurfaceAttrib not implemented
04-08 11:37:39.628 1300-1348/? W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9f0f79c0, error=EGL_SUCCESS
04-08 11:37:40.059 1300-1314/? W/ActivityManager: Activity pause timeout for ActivityRecord{a684167 u0 com.example.android.bet/.SignUp t4 f}
04-08 11:37:49.559 1300-1314/? W/ActivityManager: Launch timeout has expired, giving up wake lock!
答案 0 :(得分:2)
在public void signUpp()
方法上,给出参数View v
,如
public void signUpp(View v)
并且login
没有ID,请参阅signup=(Button) findViewById(R.id.login);