Hi Xiongzh,
Do something like the following where appropriate:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Quit Y/N?")
.setCancelable(false)
.setPositiveButton("Yes", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
MyActivity.this.finish();
}
})
.setNegativeButton("No", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id)
{
dialog.cancel();
}
});
builder.show();
return true;
}
return super.onKeyDown(keyCode, event);
}
There are probably a few bugs in the above, but hopefully you get the
basic idea.
Regards,
Michael A.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en