工厂设计模式--确定对话框

确定对话框

具体方法:

public void click1(View view){
//工厂设计模式,得到创建对话框的工厂
AlertDialog.Builder builder=new AlertDialog.Builder(this);
//设置标题
builder.setTitle(“警告请三思!”);
//设置描述信息
builder.setMessage(“若练此功,必先自宫,是否继续?”);
builder.setPositiveButton(“是”, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), “即便自宫也不一定能够成功”, Toast.LENGTH_SHORT).show();
}
});
builder.setNegativeButton(“否”, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(),”若不自宫,必不成功”,Toast.LENGTH_SHORT).show();
}
});
AlertDialog dialog=builder.create();
dialog.show();

}

你可能感兴趣的:(设计模式,对话框)