用我这个, 我己经给你写好了,你可以稍做修改就能用,title是对话框的标题icon是resID,是一张图片的ID,放在你res目录下的drawableokcmd和敬卜枝cancelcmd分别是确认和取弊清消按钮的字符串 //确认对话框的呼出亮敏 public void showDialog(String title,int icon,String msg,String okcmd,String cancelCmd){ if(okcmd==null){return;} Log.i("setDialog", "dialog dialogContent"+msg+ " dialogCmdOk"+okcmd +" dialogCmdCancel"+cancelCmd +" dialogIcon"+icon); Builder builder=new AlertDialog.Builder(this); builder.setTitle(title); if(icon>0){ builder.setIcon(icon); }else{ builder.setIcon(R.drawable.icon); } builder.setMessage(msg); builder.setPositiveButton(okcmd, newandroid.content.DialogInterface.OnClickListener(){ public void onClick(DialogInterface d, int i) { Log.i("showDialog", "onClick"); } }); if(cancelCmd!=null && cancelCmd.length()>0){ builder.setNeutralButton(cancelCmd, new android.content.DialogInterface.OnClickListener(){ public void onClick(DialogInterface d, int i) { } }); } AlertDialog dialog =builder.create(); dialog.show(); }
标签:对话框,Android,触屏