Thursday, February 28, 2013

Common event handler mistake

Here is a mistake you may very easily make with dot42:

If you are using the onClick attribute of a button in a layout file like this:
<button android:layout_height="wrap_content" 
 android:layout_width="wrap_content" 
 android:onClick="OnButtonClick" 
 android:text="@string/Sum" />
Then you should use the EventHandler attribute to ensure the event handler is included:
[EventHandler]
public void OnButtonClick(View view) {}
Note that dot42 deletes all unreachable code to minimize the size of your APK.

No comments:

Post a Comment