gpt4 book ai didi

java.lang.IllegalStateException : Could not find a method after Parse implementation 错误

转载 作者:行者123 更新时间:2023-11-29 05:11:11 25 4
gpt4 key购买 nike

我到处阅读 - 找不到解决方案。

我的项目运行良好,我在 XML 文件中声明了我希望调用 onClick 的方法,如下所示:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:theme="@style/AppTheme"
android:id="@+id/actualMainActivity"
tools:context=".ActualMainActivity"
><Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add new noob"
android:id="@+id/addNewNoob"
android:layout_marginLeft="33dp"
android:layout_marginStart="33dp"
android:onClick="addNewNoob"
android:layout_alignTop="@+id/listOfNoobs"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" /></RelativeLayout>

我的 java 类 (ActualMainActivity) 中的方法是这样的:

  public void addNewNoob(View view) {
Log.i("Tag", "you clicked the add button");
}

仅在我实现了要使用的 Parse SDK 之后,我的 Gradle 才重新同步,现在当我运行该应用程序时,我得到“找不到方法异常”。我想指出的是,当我将 onClickListener 直接分配给按钮时,如下所示: final Button a = (Button) findViewById(R.id.addNewNoob); a.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { Log.i("标签", "你点击了添加按钮"); } });

这很好用...

我在安装 SDK 时发生了什么变化?我怎样才能回到我在 XML 上编写方法并相应地执行它们的方式。

真的很困惑......提前致谢

这是日志:

02-09 11:29:34.917    2669-2669/com.example.shaked.sqliteexample02 E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.shaked.sqliteexample02, PID: 2669
java.lang.IllegalStateException: Could not find a method listOfNoobs(View) in the activity class android.view.ContextThemeWrapper for onClick handler on view class android.widget.Button with id 'listOfNoobs'
at android.view.View$1.onClick(View.java:3994)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
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:5221)
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:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NoSuchMethodException: listOfNoobs [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:3987)


提前致谢

最佳答案

Create a New Project move the old Classes to the New one and Check!

关于java.lang.IllegalStateException : Could not find a method after Parse implementation 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28409142/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com