2012年6月9日
摘要: //File指的是文件路径 private void openFile(File file){ Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //设置intent的Action属性 intent.setAction(Intent.ACTION_VIEW); //获取文件file的MIME类型 String type = getMIMEType(file); //设置intent的data和Type属性。 intent.setDataAndType(Uri.from... 阅读全文
posted @ 2012-06-09 22:16 lee0oo0 阅读(1614) 评论(0) 推荐(0) 编辑
摘要: 观察者模式:定义了一种一对多的依赖关系,让多个观察者对象同时监听某一个主题对象。这个主题对象在状态上发生变化时,会通知所有观察者对象,让他们能够自动更新自己 。以下是例子: public abstract class Citizen { List pols; String help="normal"; public void setHelp(String help){ this.help = help; } public String getHelp(){ return this.help; } public abstract void ... 阅读全文
posted @ 2012-06-09 13:37 lee0oo0 阅读(369) 评论(1) 推荐(1) 编辑
摘要: 策略模式:定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换。本模式使得算法可独立于使用它的客户而变化。以下是例子: public abstract class Strategy { public abstract void method(); } public class StrategyImplA extends Strategy{ public void method() { System.out.println("这是第一个实现"); } } public class StrategyImplB extends Strategy{ publ... 阅读全文
posted @ 2012-06-09 12:09 lee0oo0 阅读(168) 评论(0) 推荐(0) 编辑