Warning: curl_exec() has been disabled for security reasons in /pub/host/sunboyu/sunboyu/www/wp-includes/http.php on line 1022
android点击返回按钮弹出的提示 » Blog Archive 一个程序猿 孙小一,孙小二,PHP,MYSQL,LINUX,APACHE,原创技术,扯淡

android点击返回按钮弹出的提示

作者 : admin 于 2011-06-28 11:53:18 标签: ,
2011
06-28


import android.view.KeyEvent;
import android.app.AlertDialog;
import android.content.DialogInterface;
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {
AlertDialog.Builder dlg=new AlertDialog.Builder(this);
dlg.setTitle("Alert");
dlg.setMessage("退出?");
dlg.setPositiveButton("是", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
setResult(RESULT_OK);
finish();
}
});
dlg.setNegativeButton("不", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {

}
});
dlg.show();
}
return super.onKeyDown(keyCode, event);
}

发表评论




XHTML:你可以使用的标签: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(若看不到验证码,请重新加载页面。)