自定義BaseActivity,封裝一些操做。 public abstract class BaseActivity extends Activity implements OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActivityController.addActivty(this); } //以類名開啓activity protected void openActivity(Class<?> mClass) { openActivity(mClass, null); } protected void openActivity(Class<?> mClass, Bundle bundle) { Intent intent=new Intent(this,mClass); if(bundle!=null){ intent.putExtras(bundle); } startActivity(intent); } //以action開啓activity protected void actionActivity(String action){ actionActivity(action, null); } protected void actionActivity(String action,Bundle bundle){ Intent intent=new Intent(action); if(bundle!=null){ intent.putExtras(bundle); } startActivity(intent); } //以類名開啓activity protected <T> void startActivity(Class<T> mClass){ Intent intent=new Intent(this,mClass); startActivity(intent); } // 初始化控件 public abstract void initView(); @Override protected void onDestroy() { ActivityController.removeActivity(this); super.onDestroy(); } }