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();
    		
    		
    	}
    }
    

      

  • 相关阅读:
    蓝桥杯程序设计 剪格子
    sql中 1<> 1=1的用处
    form表单的6种提交方式
    js中添加监听,判断是什么事件
    angular iFrame加载资源问题
    报表往子报表里传入list
    struts 文件上传
    获取运行时的泛型类型
    Dao层抽取BaseDao
    SSH整合总结
  • 原文地址:https://www.cnblogs.com/LXJ416/p/3018506.html
Copyright © 2011-2022 走看看