我一直有問題,我的應用程序。當我啓動應用程序,它使我這個錯誤:java.lang.IllegalStateException:無法找到一個方法saveData(查看)
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.giuse.secondly, PID: 11553
java.lang.IllegalStateException: Could not find a method saveDate(View) in the activity class com.example.giuse.secondly.NewSheet for onClick handler on view class android.widget.Button with id 'button_save'
at android.view.View$1.onClick(View.java:4008)
at android.view.View.performClick(View.java:4781)
at android.view.View$PerformClick.run(View.java:19874)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
Caused by: java.lang.NoSuchMethodException: saveDate [class android.view.View]
at java.lang.Class.getMethod(Class.java:664)
at java.lang.Class.getMethod(Class.java:643)
at android.view.View$1.onClick(View.java:4001)
at android.view.View.performClick(View.java:4781)
at android.view.View$PerformClick.run(View.java:19874)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697)
當我按下按鈕SAVE,在被稱爲add_new_sheet.xml xml文件,應該保存我插入的數據。
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/save_data"
android:id="@+id/button_save"
android:textAlignment="center"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="#444444"
android:textColor="#FFF"
android:onClick="saveDate"
tools:text="Save"
tools:ignore="ObsoleteLayoutParam" />
IDE建議我創建onClick監聽器。 IDE建議我創建一個onClick監聽器。
謝謝,我錯過了。我改變了類,但現在我有另一個問題: 'code'E/SQLiteLog:(1)表geophysics_table沒有列名爲市 – Heryx
它會更好,如果你問這個完整的代碼的新問題 – androidXP