簡體   English   中英

android:onClick屬性停止工作,無法在活動中找到方法

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM