2011-09-11 6 views

답변

1
public class ExampleApp extends Activity { 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
super.onCreate(savedInstanceState); 
setContentView(R.layout.main); 
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this); 
alt_bld.setMessage("Do you want to close this window ?") 
.setCancelable(false) 
.setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
public void onClick(DialogInterface dialog, int id) { 
// Action for 'Yes' Button 
} 
}) 
.setNegativeButton("No", new DialogInterface.OnClickListener() { 
public void onClick(DialogInterface dialog, int id) { 
// Action for 'NO' Button 
dialog.cancel(); 
} 
}); 
AlertDialog alert = alt_bld.create(); 
// Title for AlertDialog 
alert.setTitle("Title"); 
// Icon for AlertDialog 
alert.setIcon(R.drawable.icon); 
alert.show(); 
} 
} 
1

당신은 아이콘이 하나가 .png 또는 .jpg, 내가보기 엔 16X16를 추천해야 alertDialog.setIcon(R.drawable.icon);

사용할 수 있습니다.

2

제목이 필요합니다. 그렇지 않으면 작동하지 않습니다.

관련 문제