zoukankan      html  css  js  c++  java
  • Android中退出程序的提示框

    @Override  
    
        public boolean onKeyDown(int keyCode, KeyEvent event) {  
    
            if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {  
    
                dialog();  
    
                return true;  
    
            }  
    
            return true;  
    
        }  
    
    protected void dialog() {  
    
            AlertDialog.Builder builder = new Builder(AccoutList.this);  
    
            builder.setMessage("确定要退出吗?");  
    
            builder.setTitle("提示");  
    
            builder.setPositiveButton("确认",  
    
            new android.content.DialogInterface.OnClickListener() {  
    
                @Override  
    
                public void onClick(DialogInterface dialog, int which) {  
    
                    dialog.dismiss();  
    
                    //AccoutList.this.finish();  
    
                    //System.exit(1);  
    
                    android.os.Process.killProcess(android.os.Process.myPid());  
    
                }  
    
            });  
    
            builder.setNegativeButton("取消",  
    
            new android.content.DialogInterface.OnClickListener() {  
    
                @Override  
    
                public void onClick(DialogInterface dialog, int which) {  
    
                    dialog.dismiss();  
    
                }  
    
            });  
    
            builder.create().show();  
    
        }  
  • 相关阅读:
    HDU 5937 Equation
    HDU 5936 Difference
    hdu 4348 To the moon
    SPOJ QTREE Query on a tree
    HDU 3966 Aragorn's Story
    Codeforces 733F Drivers Dissatisfaction
    道良心题
    dp小总结
    数据结构
    数学相关(偏数学向题目的集中地)
  • 原文地址:https://www.cnblogs.com/greywolf/p/2828343.html
Copyright © 2011-2022 走看看