在OnCreate不叫上活动 [英] OnCreate not called on Activity
本文介绍了在OnCreate不叫上活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我创建 AbstractActivity
和 AbstractFormActivity
来去掉一些样板code,其含量可是不相关的问题,但我无论如何都会发布它,也许我misunterstood东西,所以,在那里,他们分别是:
I've created AbstractActivity
and an AbstractFormActivity
to rid of some boilerplate code, their content may be irrelevant to the question, but I will post it anyway, maybe I misunterstood something so, there they are:
public abstract class AbstractActivity extends ActionBarActivity {
protected ObjectGraph graph;
@Inject
public Bus bus;
@Inject
public App app;
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
setContentView(getLayout());
setupInjection();
}
public void setupInjection() {
graph = ((App) getApplication()).createScopedGraph(getModule());
graph.inject(this);
bus.register(this);
ButterKnife.inject(this);
}
protected abstract Object getModule();
protected abstract int getLayout();
}
和
public abstract class AbstractFormActivity<T extends EntidadeBase> extends AbstractActivity implements Form<T> {
protected T entity;
protected Map<View, Boolean> formValidations;
protected AbstractFormActivity() {
formValidations = new HashMap<View, Boolean>();
}
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
protected boolean passedValidations() {
for (View key : formValidations.keySet()) {
if (!formValidations.get(key)) {
return false;
}
}
return true;
}
protected void validateAndSolidify() {
if (passedValidations()) {
solidify();
}
entity = null;
}
@Override
public void validateMoreComplexFields() {
}
}
最后我创建的那些母亲活动的执行情况:
finally I've created an Implementation of those mother Activities:
public class MercadoriaFormActivity extends AbstractFormActivity<Mercadoria> {
...
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
...
}
我的问题是,的onCreate
方法不被调用。
任何帮助是非常AP preciated。
Any help is highly appreciated.
推荐答案
的onCreate()
您目前使用的是Android的21版本中加入您应使用以下的版本,而不是
onCreate()
version you are currently using is added in Android 21. You should use version below instead:
protected void onCreate (Bundle savedInstanceState)
这篇关于在OnCreate不叫上活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文