baseパッケージでのカスタムactivity
1372 ワード
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();
}
}