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();
}
}
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();
}
}
相关文章推荐
- Android判断网路是否畅通加权限
- 解决Android studio中 logcat等乱码问题
- Android ViewDragHelper完全解析 自定义ViewGroup神器
- Android 深入理解Android中的自定义属性
- Android 手把手教您自定义ViewGroup(一)
- Android 自定义View (四) 视频音量调控
- android,activity跳转Html
- Android 自定义View (三) 圆环交替 等待效果
- Android 自定义View (二) 进阶
- Android 自定义View (一)
- android 招聘需求整理
- Android"沉浸式"体验
- Android-Universal-Image-Loader 图片异步加载类库的使用(超详细配置)
- android 屏幕底部出现菜单
- Android 属性动画(Property Animation) 完全解析 (下)
- android bitmap的内存分配和优化
- android bitmap的内存分配和优化
- android bitmap的内存分配和优化
- Android 属性动画(Property Animation) 完全解析 (上)
- Android_按两次返回键退出程序和长按返回键退出程序