zoukankan      html  css  js  c++  java
  • AlertDialog

          

    new AlertDialog.Builder(this)
                    .setTitle("删除")
                    .setMessage("确认删除吗?")
                    .setPositiveButton("删除", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(MainActivity.this,"删除了",Toast.LENGTH_SHORT).show();
                        }
                    })
                    .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(MainActivity.this,"取消删除",Toast.LENGTH_SHORT).show();
    
                        }
                    })
                    .show();
    普通对话框

         

    我们使用setSingleChoiceItems可以设置单选项。这个与setmessage是不能共存的,且优先级小于setmessage。

    final String [] items = new String[]{"红","黄","蓝","绿","灰"};
            new AlertDialog.Builder(this)
                    .setTitle("选择颜色")
                    //.setMessage("确认删除吗?")
                    .setSingleChoiceItems(items, 2, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(MainActivity.this,items[which],Toast.LENGTH_SHORT).show();
    //关闭dialog
                            dialog.dismiss();
                        }
                    })
                    //
                    .setPositiveButton("删除", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(MainActivity.this,"删除了",Toast.LENGTH_SHORT).show();
                        }
                    })
                    .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            Toast.makeText(MainActivity.this,"取消删除",Toast.LENGTH_SHORT).show();
    
                        }
                    })
                    .show();
    单选对话框
  • 相关阅读:
    CodeForces 385D: Bear and Floodlight
    UVA
    SGU 495: Kids and Prizes
    CodeForces 148D: Bag of mice
    HDU 4405: Aeroplane chess
    HDU 4336: Card Collector
    UVA
    POJ 2577: Interpreter
    伪类选择器 伪原色选择器 选择器的优先级
    复习html CSS选择器 组合选择器和属性选择器
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/12714904.html
Copyright © 2011-2022 走看看