/** * @setIcon 设置对话框图标 * @setTitle 设置对话框标题 * @setMessage 设置对话框消息提示 * setXXX方法返回Dialog对象,因此可以链式设置属性 */ private void showNormalDialog() { final AlertDialog.Builder normalDialog = new AlertDialog.Builder(ModifyActivity.this); normalDialog.setIcon(R.drawable.h100); normalDialog.setTitle("标题内容"); normalDialog.setMessage(tv.getText()); normalDialog.setPositiveButton("确定", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //...To-do hcontent = h_content.getText().toString(); hoperate = tv.getText().toString(); } }); normalDialog.setNegativeButton("关闭", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //...To-do } }); // 显示 normalDialog.show(); }
android AlertDialog 对话框的基本使用
最新推荐文章于 2023-09-18 12:04:43 发布