解决AlertDialog自定义布局没有dismiss()方法的问题

final AlertDialog.Builder builder = new AlertDialog.Builder(XitongMessagesMoreActivity.this);
builder.setTitle("标题");
LayoutInflater inflater = LayoutInflater.from(XitongMessagesMoreActivity.this);
final View DialogView = inflater .inflate ( R.layout.fengxiantishi, null);//1、自定义布局
TextView fxts = (TextView) DialogView.findViewById(R.id.fxts_show);//自定义控件
builder.setView(DialogView);
final AlertDialog dialog = builder.create(); //重点
fxts.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        dialog.dismiss();
    }
});
dialog.show();

你可能感兴趣的:(android)