2011-09-10 7 views
1

ボタンを作成しましたが、そのボタンをクリックすると新しいダイアログボックスが表示されます。このダイアログボックスでアイコンとtext.textは表示されますがアイコン(イメージ)はダイアログボックスに表示されません。 ここに私はあなたが空でない文字列でのsetTitleを呼び出す必要がありますDialogBoxでボタンをクリックしているときにアイコン(画像)を設定する方法

Button btnteam_westernbulldogs=new Button(this); 
    btnteam_westernbulldogs.setId(team_westernbulldogsid); 
    btnteam_westernbulldogs.setBackgroundResource(R.drawable.team_westernbulldogs); 
      public void onClick(View v){ 

       createbtnteam_westernbulldogs(); 
      } 
    }); 


public void createbtnteam_westernbulldogs() 
{ 
    AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
    alertDialog.setIcon(R.drawable.team_westernbulldogs); 
    alertDialog.setMessage("What kind of Banner do you Want to Create?"); 
    alertDialog.setButton("Text", new DialogInterface.OnClickListener() { 
     public void onClick(DialogInterface dialog, int which) { 
      createText(); 

     } 
    alertDialog.setIcon(R.drawable.icon); 
    alertDialog.show(); 
     }  }); 

答えて

1
public void createbtnteam_westernbulldogs() 
{ 
AlertDialog alertDialog = new AlertDialog.Builder(this).create(); 
alertDialog.setIcon(R.drawable.team_westernbulldogs); 
alertDialog.setTitle("What kind of Banner do you Want to Create?"); 
alertDialog.setButton("Text", new DialogInterface.OnClickListener() { 
    public void onClick(DialogInterface dialog, int which) { 
     createText(); 

    } 
alertDialog.setIcon(R.drawable.icon); 
alertDialog.show(); 
}  }); 
0

コーディング! アイコンもタイトルがある場合にのみ表示されます。

2
Try this.. 

    AlertDialog.Builder builder = new AlertDialog.Builder(this); 
    builder.setMessage("Are you sure you want to exit?") 
    .setIcon(R.drawable.icon)  
    .setCancelable(false)  
    .setPositiveButton("Yes", new DialogInterface.OnClickListener() 
    {   
    public void onClick(DialogInterface dialog, int id) 
     {     
     MyActivity.this.finish();   
    }  
     })  
     .setNegativeButton("No", new DialogInterface.OnClickListener() 
     {   
      public void onClick(DialogInterface dialog, int id) 
      {     
      dialog.cancel();   
      }  
      }); 
     AlertDialog alert = builder.create(); 
+0

屋、sir.Iはそれを得たのuに感謝します。 – Mercy

関連する問題