简体   繁体   English

android:onClick属性停止工作,无法在活动中找到方法

[英]android:onClick attribute stopped working, can't find method in activity

I have bunch of buttons like this 我有一堆这样的按钮

<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"
/>

And in activity coresponding methods like this 在像这样的活动核心响应方法中

public void b_settings(View view){
    Intent intent = new Intent(Main.getInstance(), SettingsActivity.class);
    startActivity(intent);
}

All methods exist and are public. 所有方法都存在并且是公开的。 Everythig seems ok. Everythig似乎还可以。 And I worked fine long time. 我工作了很长时间。 Than it suddenly started to give this error. 比它突然开始给这个错误。

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'

But I am sure that method is actualy present in Main and is public and with correct signature. 但是我确信该方法实际上已经存在于Main中,并且是公开的并且具有正确的签名。 Bug is showing only on devices and emulator with older apis. 仅在使用较旧api的设备和仿真器上显示错误。 (tested 2.2 2.3) On new apis (4.*) everything works fine. (经过测试2.2 2.3)在新的API(4. *)上,一切正常。 As far as I know I didnt changed anything regarding xml with buttons or corresponding method in activity. 据我所知,我没有在按钮中更改任何有关xml的按钮或相应的方法。 It just stopped working for no obvious reason. 它只是没有明显的原因就停止了工作。

In manifest min sdk is 8 and target is 10. Build target in properties is 4.2 在清单中,最小sdk为8,目标为10。属性中的构建目标为4.2。

Did this happen to anyone before? 以前有没有发生过这种情况? Any clues? 有什么线索吗? thanks 谢谢

i thought u took same project with another project. 我以为你参加了另一个项目的同一项目。 but ur using in layout as 但是您在布局中使用

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM