user1256477
user1256477

Reputation: 11201

alertdialog show an image and a title

I'm doing an AlertDialog, it has an image and a title:

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();

The title is not shown:

enter image description here

where is the title? I can't understand!

Upvotes: 2

Views: 3132

Answers (1)

TronicZomB
TronicZomB

Reputation: 8747

I am not 100% sure if this will make a difference but I don't think the extra "noise", for lack of a better term is necessary in the .setIcon. Try:

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();

Upvotes: 2

Related Questions