This is the code that does something in response to a View object being clicked (e.g. a button being clicked):
final OnClickListener exampleListener = new OnClickListener()
{
public void onClick(View arg0) {
//Code here that does something upon click event.
}
};
Button exampleButton = (Button)this.findViewById(R.id.firstButton);
exampleButton.setOnClickListener(exampleListener);
I don't understand the code. Is this code creating an overridden method called onClick which belongs to the parent OnClickListener class on the fly?
Is the following code equivalent to the above code?:
final OnClickListener exampleListener = OnClickListener.onClick()
{
public void onClick(View arg0) {
//Code here that does something upon click event.};
}