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