From the android development perspective, while you are programming which way do you prefer to implement for listener? Or which way do you think is the best for readable code? I gave two example about these things but think more complex classes such as which has more than one Listener:)
First example which is an Anonymous Class:
public class SenderReceiverActivity extends Activity {
Button cancelButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sending);
cancelButton = (Button) findViewById(R.id.button1);
cancelButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
}
});
}}
Second example which is implementing interface :
public class SenderReceiverActivity extends Activity implements OnClickListener {
Button cancelButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.sending);
cancelButton = (Button) findViewById(R.id.button1);
cancelButton.setOnClickListener(this);
}
public void onClick(View v) {
}
}