Android: easier click listeners in 1.6

Romain guy just posted a really cool improvement of button click listeners for the Android SDK 1.6 on the official Android Developers Blog.

Instead of having every time this recurring bunch of code to set up a simple click listener you can now just add
<Button android:onClick="myClickHandler" />
to your button element in your layout's XML file.

Finally the code to handle the click is as simple as that:
class MyActivity extends Activity {
  public void myClickHandler(View target) {
  // Do stuff

No comments:

Post a Comment