您的位置:首页 > 移动开发 > Android开发

Java建造者模式,Android建造者模式的AlertDialog

2016-04-25 11:10 411 查看
在java中的类图:



package com.panda.pattern;

/***
* 模拟Android弹出框
* @author hp
*
*/
public class AlertDialog {

public static class Builder {

public Builder() {

}

public Builder setTitle(String title) {
System.out.println("这是标题:"+title);
return this;
}

public Builder setIcon(String title) {
System.out.println("这是图标:"+title);
return this;
}

public AlertDialog show() {
return new AlertDialog();
}
}

}

package com.panda.pattern;

import com.sina.build.AlertDialog.Builder;

public class Test {

public static void main(String[] args) {

new AlertDialog.Builder().setTitle("这是标题").setIcon("这是图标").show();

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: