2

我正在做一个 AlertDialog,它有一个图像和一个标题:

AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Recuerda tirar del cable");
builder.setIcon(context.getResources().getDrawable(R.drawable.tira_cable));

builder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
        //actions
      }
});
AlertDialog dialog = builder.create();
dialog.show();

标题未显示:

在此处输入图像描述

标题在哪里?我无法理解!

4

1 回答 1

2

我不是 100% 确定这是否会有所作为,但我不认为额外的“噪音”,因为在.setIcon. 尝试:

AlertDialog.Builder builder = new AlertDialog.Builder(activity);
builder.setTitle("Recuerda tirar del cable");
builder.setIcon(R.drawable.tira_cable);

builder.setPositiveButton(R.string.accept, new DialogInterface.OnClickListener() {
      public void onClick(DialogInterface dialog, int id) {
        //actions
      }
});
AlertDialog dialog = builder.create();
dialog.show();
于 2013-04-30T14:40:39.890 回答