@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
// 按下键盘上返回按钮
if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0 && MainActivity.this.isTaskRoot())
{
new AlertDialog.Builder(this).setIcon(R.drawable.icon).setTitle("Exit").setMessage("Exit.....?")
.setNegativeButton("Cancel", new DialogInterface.OnClickListener()
{
@Override
public void onClick(DialogInterface dialog, int which)
{
}
}).setPositiveButton("Confirm", new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog, int whichButton)
{
finish();
}
}).show();
return true;
} else
{
return super.onKeyDown(keyCode, event);
}
}
Android 返回键
最新推荐文章于 2024-08-21 22:09:39 发布