zoukankan      html  css  js  c++  java
  • AlertDialog.Builder选择对话框

    1.选择对话框:

     final String[] formatSettingItems = {"ASCII","Hexadecimal", "Decimal"};
    
    new AlertDialog.Builder(context).setTitle("Data Format")
                .setItems(formatSettingItems, new DialogInterface.OnClickListener() 
                {
                    @Override
                    public void onClick(DialogInterface dialog, int which)
                    {    
                        MenuItem item = myMenu.findItem(MENU_FORMAT);
                        if(0 == which)
                        {                        
                            inputFormat = FORMAT_ASCII;
                            item.setTitle("Format - "+ formatSettingItems[0]);
                        }
                        else if(1 == which)
                        {
                            inputFormat = FORMAT_HEX;
                            item.setTitle("Format - "+ formatSettingItems[1]);
                        }
                        else
                        {
                            inputFormat = FORMAT_DEC;
                            item.setTitle("Format - "+ formatSettingItems[2]);                        
                        }
                    }
                }).show();          

    效果图:

    选择后:

    2.带确认和取消按钮的对话框:

               new AlertDialog.Builder(context)
                       .setMessage("此手机号已注册过,请直接登录或找回密码")
                       .setPositiveButton("确认", new DialogInterface.OnClickListener() {
                           @Override
                           public void onClick(DialogInterface dialogInterface, int i) {
                               // TODO Auto-generated method stub
                               finish();
                           }
                       })
                       .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                           @Override
                           public void onClick(DialogInterface dialogInterface, int i) {
                               // TODO Auto-generated method stub
                           }
                       }).show();

    效果图:

  • 相关阅读:
    GUC-3 模拟CAS算法
    GUC-2 原子性
    GUC-1 volatile
    NIO-5补充
    NIO-4pipe
    NIO-3网络通信(非阻塞)
    NIO-3网络通信
    NIO-1缓冲区(Buffer)
    NIO-2通道(Channel)
    eclipse安装spring boot插件spring tool suite
  • 原文地址:https://www.cnblogs.com/xiaobijia/p/5377629.html
Copyright © 2011-2022 走看看