final AlertDialog ad = new android.app.AlertDialog.Builder(context).create();
ad.setCanceledOnTouchOutside(true);
ad.show();
//关键在下面的两行,使用window.setContentView,替换整个对话框窗口的布局
Window window = ad.getWindow();
window.setContentView(R.layout.alert_dialog);
View tv_copy = window.findViewById(R.id.tv_copy);
tv_copy.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
ToastUtils.showToast("复制", context);
ad.dismiss();
}
});
自定义dialog
最新推荐文章于 2020-06-09 14:32:39 发布