2011-09-10 4 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

나중에, 유 장군님이있어 감사합니다. – Mercy

관련 문제