[英]android:onClick attribute stopped working, can't find method in activity
我有一堆这样的按钮
<cz.applmartin.quicksketch.Gui.Buttons.CopyDragableImageButton
android:id="@+id/b_settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="b_settings"
android:background="@drawable/s_settings"
/>
在像这样的活动核心响应方法中
public void b_settings(View view){
Intent intent = new Intent(Main.getInstance(), SettingsActivity.class);
startActivity(intent);
}
所有方法都存在并且是公开的。 Everythig似乎还可以。 我工作了很长时间。 比它突然开始给这个错误。
java.lang.IllegalStateException: Could not find a method b_settings(View) in the activity class cz.applmartin.quicksketch.Main for onClick handler on view class cz.applmartin.quicksketch.Gui.Buttons.CopyDragableImageButton with id 'b_settings'
但是我确信该方法实际上已经存在于Main中,并且是公开的并且具有正确的签名。 仅在使用较旧api的设备和仿真器上显示错误。 (经过测试2.2 2.3)在新的API(4. *)上,一切正常。 据我所知,我没有在按钮中更改任何有关xml的按钮或相应的方法。 它只是没有明显的原因就停止了工作。
在清单中,最小sdk为8,目标为10。属性中的构建目标为4.2。
以前有没有发生过这种情况? 有什么线索吗? 谢谢
我以为你参加了另一个项目的同一项目。 但是您在布局中使用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.