我已经创建了AbstractActivity
和AbstractFormActivity
来摆脱一些样板代码,他们的内容可能与问题无关,但无论如何我都会发布它,也许我误解了一些东西,他们在那里:
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() {
}
}
最后,我创建了这些母亲活动的实施:
public class MercadoriaFormActivity extends AbstractFormActivity<Mercadoria> {
...
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
super.onCreate(savedInstanceState, persistentState);
}
...
}
我的问题是没有调用onCreate
方法。
非常感谢任何帮助。
答案 0 :(得分:37)
onCreate()
版本已在Android 21中添加。您应该使用以下版本:
protected void onCreate (Bundle savedInstanceState)
答案 1 :(得分:0)
我也遇到了同样的问题。 几个小时后,我发现了我的错误,而是在 (savedInstanceState: Bundle, persistentState: PersistableBundle) 函数上覆盖了下面的一个。
Options -MultiViews
RewriteEngine On
# handle configurator
RewriteRule ^(configurator)/(.+) $1.php?url=$2 [L,QSA,NC]
# To internally forward /dir/file to /dir/file.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/mypage/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
# front controller rule
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [L,QSA]