0
我有两部分代码。一个有错误,但另一个没有。setDisplayHomeAsUpEnabled()错误:无法从静态上下文中引用非静态方法
ActionBar theActionBar = getSupportActionBar();
if (theActionBar != null) {
// error: non-static method cannot be referenced from a static context
ActionBar.setDisplayHomeAsUpEnabled(true);
}
。
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
。
有没有人碰巧知道如何解释这个?
'ActionBar.set'相比'theActionBar.set' .. 。使用实际的实例变量,而不是类 –
这是我的不好。没有注意到错字。非常感谢。 – Leonard