系统dialog:

	AlertDialog.Builder builder = new Builder(CallSmsSafeActiviy.this);
					builder.setTitle("删除提示");
					builder.setMessage("确认解除"+list.get(position).getNumber()+"号码黑名单设置");
					builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
						
						@Override
						public void onClick(DialogInterface arg0, int arg1) {
							// TODO Auto-generated method stub
							blackdao.delete(list.get(position).getNumber());
							list.remove(position);
							blackAdapter.notifyDataSetChanged();
							
						}

						
					});
					builder.setNegativeButton("取消", null);
					builder.show();

 

 

 

自定义Dialog:

AlertDialog.Builder builder = new Builder(
						CallSmsSafeActiviy.this);
				View view = View.inflate(CallSmsSafeActiviy.this,
						R.layout.dalog_add_blacknumber, null);
				final EditText et_input_number = (EditText) view
						.findViewById(R.id.number);
				Button btn_ok = (Button) view.findViewById(R.id.btn_ok);
				cb_message = (CheckBox) view.findViewById(R.id.cb_message);
				cb_message.setChecked(false);
				cb_phone = (CheckBox) view.findViewById(R.id.cb_phone);
				cb_phone.setChecked(false);
				Button btn_cancel = (Button) view.findViewById(R.id.btn_cancel);

				btn_ok.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						// TODO Auto-generated method stub
						// Toast.makeText(CallSmsSafeActiviy.this, "ok",
						// 0).show();
						phone_num = et_input_number.getText().toString().trim();
						if (cb_message.isChecked() == true) {
							// 添加数据库,但是要在第二次重新加载的时候才会显示
							blackdao.add(phone_num, "1");
							Toast.makeText(CallSmsSafeActiviy.this,
									"短信黑名单添加成功", 0).show();
							/*
							 * 更新listview上面的数据,添加之后即刻刷新listview上面的数据,
							 * 因为listview上面的数据是是和List<blackNumberInfo>
							 * list关系最为密切 而List<blackNumberInfo>
							 * list则和blackNumberInfo有关系,那么就要更新
							 * List<blackNumberInfo> list里面的内容。
							 */
							blackNumberInfo info = new blackNumberInfo();
							info.setMode("1");
							info.setNumber(phone_num);
							list.add(0, info);

							blackAdapter.notifyDataSetChanged();// 刷新数据库
							dialog.dismiss();

						} else if (cb_phone.isChecked() == true) {
							blackdao.add(phone_num, "2");
							Toast.makeText(CallSmsSafeActiviy.this,
									"电话黑名单添加成功", 0).show();

							blackAdapter.notifyDataSetChanged();
							dialog.dismiss();

						} else if (messageChecked == true
								&& phoneChecked == true) {
							blackdao.add(phone_num, "3");
							Toast.makeText(CallSmsSafeActiviy.this,
									"电话金额和短信黑名单添加成功", 0).show();
							blackAdapter.notifyDataSetChanged();
							dialog.dismiss();

						} else {
							Toast.makeText(CallSmsSafeActiviy.this,
									"请选择要拦截的类型", 0).show();
						}

					}
				});

				btn_cancel.setOnClickListener(new OnClickListener() {

					@Override
					public void onClick(View arg0) {
						dialog.dismiss();
					}
				});
				dialog = builder.create();
				dialog.setView(view);
				dialog.show();
			}
		});