zoukankan      html  css  js  c++  java
  • Android简单实现对话框

    网络111 刘修军

    简单实现对话框,界面如下:

    代码:

    public class MyDialogActivity extends Activity implements OnClickListener {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            Button button1=(Button) findViewById(R.id.button1);
            this.registerForContextMenu(button1);//注册菜单
            button1.setOnClickListener(this);
        }
    
    	@Override
    	public void onClick(View arg0) {
    		// TODO Auto-generated method stub
    		AlertDialog.Builder alertdialog=new AlertDialog.Builder(this);
    		alertdialog.setTitle("提示");
    		alertdialog.setMessage("你真的要退出吗?");
    		alertdialog.setPositiveButton("是", new DialogInterface.OnClickListener() {
    			
    			@Override
    			public void onClick(DialogInterface dialog, int which) {
    				// TODO Auto-generated method stub
    				setContentView(R.layout.login); // 跳转到Login界面
    			}
    		})
    		.setNegativeButton("否",new DialogInterface.OnClickListener() {
    			
    			@Override
    			public void onClick(DialogInterface dialog, int which) {
    				// TODO Auto-generated method stub
    				dialog.cancel();
    				
    			}
    		});
    		
    		alertdialog.show();
    		
    		
    	}
    }
    

      

  • 相关阅读:
    矩阵树定理
    随机乱搞算法
    数学
    BZOJ——3412: [Usaco2009 Dec]Music Notes乐谱
    BZOJ—— 3402: [Usaco2009 Open]Hide and Seek 捉迷藏
    洛谷—— P2884 [USACO07MAR]每月的费用Monthly Expense
    洛谷—— P2417 课程
    洛谷—— P1577 切绳子
    COGS 2598. 美丽的感觉
    10.23 模拟赛
  • 原文地址:https://www.cnblogs.com/LXJ416/p/3018506.html
Copyright © 2011-2022 走看看