今天看到这篇文章:http://www.androiddesignpatterns.com/2012/05/using-newinstance-to-instantiate.html public class MyFragment extends Fragment { public static MyFragment newInstance(int index) { MyFragment f = new MyFragment(); Bundle args = new Bundle(); args…
工厂模式(Factory Method):定义一个用于创建对象的接口,让子类决定实例化哪一个类.工厂方法使一个类的实例化延迟到了子类. 1.业务逻辑 1.1.父类Operation package com.designmode.factory; public abstract class Operation { protected int numberA; protected int numberB; public void setValue(int numberA,int numberB){…