Proper way to implement Android XML onClick attribute in Activity

Posted by Austyn Mahoney on Programmers See other posts from Programmers or by Austyn Mahoney
Published on 2012-06-14T21:06:42Z Indexed on 2012/07/01 15:23 UTC
Read the original article Hit count: 252

Filed under:

I have used the android:onClick attribute extensively in my XML layouts for my Android application.

Example:

<Button
    android:id="@+id/exampleButton"
    android:onClick="onButtonClick" />

Is it proper to create an Interface to enforce the implementation of those onClick methods in Activities that use that layout file?

public interface MyButtonInterface {
    public onButtonClick(View v);
}

© Programmers or respective owner

Related posts about android