You should add the method in the activity file. That method is declared as onclick atrribute of the button with the name SaveData.You should implement this method in your activity file. For example look at this document. https://developer.android.com/reference/android/widget/Button.html
On Thu, Sep 29, 2016 at 11:16 AM, Giuseppe Guarino < giuseppe.gu1...@gmail.com> wrote: > Hi, I'm developing an App that should receive data and save them in the > SQLdatabase, but I have a problem. > When I press the Save Button, the App stops the process with this error: > E/AndroidRuntime: FATAL EXCEPTION: main Process: > com.example.giuse.secondly, PID: 2615 java.lang.IllegalStateException: > Could not find a method saveData(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:4007) > at android.view.View.performClick(View.java:4780) at android.view.View$ > PerformClick.run(View.java:19866) 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:903) > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused > by: java.lang.NoSuchMethodException: saveData [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:4000) at > android.view.View.performClick(View.java:4780) > at android.view.View$PerformClick.run(View.java:19866) 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:903) > at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) > Application terminated. > > When I press the button Save, in the xml file, called add_new_sheet xml, > should save the data that I inserted. > > -- > You received this message because you are subscribed to the Google Groups > "Android Developers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to android-developers+unsubscr...@googlegroups.com. > To post to this group, send email to android-developers@googlegroups.com. > Visit this group at https://groups.google.com/group/android-developers. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/android-developers/c315a942-8ffd-42c3-a146- > 1ddc4a6d29af%40googlegroups.com > <https://groups.google.com/d/msgid/android-developers/c315a942-8ffd-42c3-a146-1ddc4a6d29af%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/CABHzXAQGCbRPVGfQjai-7L5ZTgity1AMNmi%2Bm-CNPHq1L7VzDg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.