Android的消息框处理方法

Toast toast = new Toast(Main.this);   
                toast.setView(view);   
                toast.setDuration(Toast.LENGTH_LONG);   
                toast.show();

 

    Builder dlg=new Builder(ServerInfoUpdate.this);
    dlg.setTitle("Error");
      dlg.setMessage("Unknown error.");
      dlg.show();


            // 一个简单的弹出对话框   
            return new AlertDialog.Builder(this).setTitle("这是一个简单的弹出对话框的 Demo")   
                    .create();   
  
            // 一个相对复杂的弹出对话框   
            return new AlertDialog.Builder(this)   
                    .setTitle("标题") // 设置标题   
                    // .setCustomTitle(View) // 以一个 View 作为标题    
                    .setIcon(R.drawable.icon01) // 设置标题图片   
                    // .setMessage("信息") // 需要显示的弹出内容   
                    .setPositiveButton("确定", new OnClickListener() { // 设置弹框的确认按钮所显示的文本,以及单击按钮后的响应行为   
                        @Override 
                        public void onClick(DialogInterface a0, int a1) {   
                            TextView txtMsg = (TextView) Main.this.findViewById(R.id.txtMsg);   
                            txtMsg.append("单击了对话框上的“确认”按钮\n");   
                        }   
                    })   
                    .setItems(R.array.ary, new DialogInterface.OnClickListener() { // 弹框所显示的内容来自一个数组。数组中的数据会一行一行地依次排列   
                        public void onClick(DialogInterface dialog,    int which) {   
                        }   
                    })   
                    // 其他常用方法如下   
                    // .setMultiChoiceItems(arg0, arg1, arg2)   
                    // .setSingleChoiceItems(arg0, arg1, arg2)   
                    // .setNeutralButton(arg0, arg1)   
                    // .setNegativeButton(arg0, arg1)   
                    .create();   
  
         
            // 弹出进度条对话框   
            ProgressDialog progress = new ProgressDialog(this);   
            progress.setMessage("loading...");   
            return progress;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值