Let the button have the Return key function is very simple, in the Click event Plus Finish (); OK.
Such as:
Copy Code code as follows:
public void OnClick (View v) {
Finish ();
}
Finish () simply exits the activity from its current state, but the resource is not cleaned up.
In fact, the Android mechanism determines that users cannot completely exit application, that is, using System.exit ().
Android decides when to release the program from memory, and when the system does not have available memory, it will destroy the application in a certain priority.
The Android phone operating system has a garbage disposal mechanism, so don't worry about it, use the finish () method.
Override Return Key:
Copy Code code as follows:
public boolean onKeyDown (int keycode,keyevent event) {
if (keycode = = Keyevent.keycode_back && event.getrepeatcount () = = 0) {
Here rewrite the return key
return true;
}
return false;
}