首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

Android创办AlertDialog对话框 ==之一

2012-12-23 
Android创建AlertDialog对话框之一activity如下//设置对话框的图标builder.setIcon(R.drawable.ic_launc

Android创建AlertDialog对话框 ==之一

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();


热点排行