I have an Activity with one button to quit the Activity.
Through the layout.xml I have to set the OnClick event to cmd_exit and a call to 'this.finish()' works fine
public void cmd_exit(View editLayout){
this.finish();
}
, but when I add a OnClickListener instead
cmd_exit = (Button) this.findViewById(R.id.cmd_ExitApp);
cmd_exit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
this.finish() gives error. It has to be only finish().
I understand that finish() lives in the Activity class so my question is how is it working in the second snippet?