我想用自己的图片定义AlertDialog.Builder的按钮,比如下面的取消按钮的背景图片,用什么实现啊。谢谢new AlertDialog.Builder(ICU_login.this)
.setTitle("标题")
.setMessage("自定义按钮")
.setNegativeButton("取消", null)
.show();
.setTitle("标题")
.setMessage("自定义按钮")
.setNegativeButton("取消", null)
.show();
.setMessage("自定义按钮")
.setNegativeButton("取消", null)
这些都不要,只要一个setView(View view),view的布局,你照着系统弹出框来写
TextView title = new TextView(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER;
title.setText("标题");
title.setLayoutParams(params);
builder.setCustomTitle(title);
builder.show();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
TextView title = new TextView(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.CENTER;
title.setText("标题");
title.setLayoutParams(params);
builder.setView(title);
builder.show();你现在的布局只是一个textview,也就是说只有标题,内容、按钮这些你都没有指定,所以最好是将TextView title 换成一个布局,可以在代码中定义,也可以用xml配置,然后builder.setView(view);
放到里面去