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;

更多相关文章

  1. (OK) 在CentOS7—编译OpenSSL 静态库—for—Android
  2. Android(安卓)侧滑,左滑,右滑
  3. Android(安卓)对话框中的进度条 ProgressDialog
  4. Android(安卓)工程目录简单结构
  5. Android(安卓)OpenCV java.lang.UnsatisfiedLinkError n_mat
  6. adnroid actionbar属性
  7. Android(安卓)App 隐藏显示标题栏、状态栏、导航栏
  8. android 鸡蛋在哪只鞋子小综合
  9. Android视频播放之JiaoZiVideoPlayer框架的使用

随机推荐

  1. Android 使用com.j256.ormlite
  2. android手势创建及识别
  3. 理解 ViewStub 原理
  4. android repo/git server 建立过程(2)
  5. Android dependency ‘androidx.core:cor
  6. android中Handler源码的分析文章
  7. Android中自定义View仿京东秒杀倒计时
  8. 面试题:IPC(跨进程通信)
  9. GridView做所有程序主菜单
  10. Android TelephonyManager类