Android创建AlertDialog对话框 ==之一

activity如下
//设置对话框的图标builder.setIcon(R.drawable.ic_launcher);//设置对话框的标题builder.setTitle("自定义普通对话框");builder.setItems(new String[]{"red","yellow","blue","green"}, new DialogInterface.OnClickListener(){//该方法which参数代表用户单击的那个列表项@Overridepublic void onClick(DialogInterface dialog, int which) {switch(which){case 0:Toast.makeText(LifeActivity.this, "red", Toast.LENGTH_SHORT).show();break;case 1:Toast.makeText(LifeActivity.this, "yellow", Toast.LENGTH_SHORT).show();break;case 2:Toast.makeText(LifeActivity.this, "blue", Toast.LENGTH_SHORT).show();break;case 3:Toast.makeText(LifeActivity.this, "green", Toast.LENGTH_SHORT).show();break;}}});builder.create().show();