当前位置: 代码迷 >> Android >> Android的讯息框处理方法
  详细解决方案

Android的讯息框处理方法

热度:45   发布时间:2016-05-01 20:49:15.0
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;

  相关解决方案