I have Activityone button to exit Activity.
Through layout.xmlI need to set the event OnClickto cmd_exit, and calling this.finish () function works fine
public void cmd_exit(View editLayout){
this.finish();
}
but when i add OnClickListenerinstead
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 an error. It should be only finish().
I understand that he finish()lives in the classroom Activity, so my question is: how does it work in the second fragment?
source
share