I have two parts of codes. One has the error, but the other doesn't.
ActionBar theActionBar = getSupportActionBar();
if (theActionBar != null) {
// error: non-static method cannot be referenced from a static context
ActionBar.setDisplayHomeAsUpEnabled(true);
}
.
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
.
Does anyone happen to know how to explain this?
Your error says it all. Just change this line:
ActionBar.setDisplayHomeAsUpEnabled(true);
to
theActionBar.setDisplayHomeAsUpEnabled(true);
or just change your code to look like this:
if(getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments