setDisplayHomeAsUpEnabled() error: non-static method cannot be referenced from a static context

Leonard

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?

Nongthonbam Tonthoi

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

"Non-static method cannot be referenced from static context" error

From Dev

Error:non static method 'edit' cannot be referenced in static context

From Java

non static method cannot be referenced from a static context

From Dev

non-static method getIntent() cannot be referenced from a static context

From Dev

Non-static method getSocketFactory cannot be referenced from a static context

From Java

Error: Non-static method 'findViewById(int)' cannot be referenced from a static context

From Dev

error: non-static method setListMovie(ArrayList<Movie>) cannot be referenced from a static context

From Java

getting Error: non-static method 'getResources()' cannot be referenced from a static context

From Dev

error: non-static method unbind() cannot be referenced from a static context

From Dev

error: non-static method getActivity() cannot be referenced from a static context

From Dev

How to resolve this error?:non-static method maxOf(int,int) cannot be referenced from a static context

From Java

i am getting a error in animate() which is "error: non-static method animate() cannot be referenced from a static context"

From Dev

Error: Non-static variable super cannot be referenced from a static context >>but i use static keyword

From Dev

Trying to get my show-method to work (Non static method cannot be referenced from static context)

From Java

Cannot be referenced from static context error

From Dev

non-static variable s cannot be referenced from a static context

From Dev

non static variable this cannot be referenced from a static context

From Java

"non-static variable this cannot be referenced from a static context"?

From Java

non-static class cannot be referenced from a static context

From Dev

java: non-static variable this cannot be referenced from a static context

From Dev

Non-static variable filepath cannot be referenced from a static context

From Dev

Non static variable cannot be referenced from static context java

From Dev

non-static variable cannot be referenced from static context [JAVA]

From Dev

non-static variable cannot be referenced from a static context java

From Dev

Non-static edit() cannot be referenced from a static context

From Dev

non static setGravity cannot be referenced from static context

From Dev

Non-static variable cannot be referenced from a static context?

From Dev

Map.merge .. non-static method cannot be referenced from static context

From Dev

non-static method matcher(CharSequence) cannot be referenced from a static context

Related Related

  1. 1

    "Non-static method cannot be referenced from static context" error

  2. 2

    Error:non static method 'edit' cannot be referenced in static context

  3. 3

    non static method cannot be referenced from a static context

  4. 4

    non-static method getIntent() cannot be referenced from a static context

  5. 5

    Non-static method getSocketFactory cannot be referenced from a static context

  6. 6

    Error: Non-static method 'findViewById(int)' cannot be referenced from a static context

  7. 7

    error: non-static method setListMovie(ArrayList<Movie>) cannot be referenced from a static context

  8. 8

    getting Error: non-static method 'getResources()' cannot be referenced from a static context

  9. 9

    error: non-static method unbind() cannot be referenced from a static context

  10. 10

    error: non-static method getActivity() cannot be referenced from a static context

  11. 11

    How to resolve this error?:non-static method maxOf(int,int) cannot be referenced from a static context

  12. 12

    i am getting a error in animate() which is "error: non-static method animate() cannot be referenced from a static context"

  13. 13

    Error: Non-static variable super cannot be referenced from a static context >>but i use static keyword

  14. 14

    Trying to get my show-method to work (Non static method cannot be referenced from static context)

  15. 15

    Cannot be referenced from static context error

  16. 16

    non-static variable s cannot be referenced from a static context

  17. 17

    non static variable this cannot be referenced from a static context

  18. 18

    "non-static variable this cannot be referenced from a static context"?

  19. 19

    non-static class cannot be referenced from a static context

  20. 20

    java: non-static variable this cannot be referenced from a static context

  21. 21

    Non-static variable filepath cannot be referenced from a static context

  22. 22

    Non static variable cannot be referenced from static context java

  23. 23

    non-static variable cannot be referenced from static context [JAVA]

  24. 24

    non-static variable cannot be referenced from a static context java

  25. 25

    Non-static edit() cannot be referenced from a static context

  26. 26

    non static setGravity cannot be referenced from static context

  27. 27

    Non-static variable cannot be referenced from a static context?

  28. 28

    Map.merge .. non-static method cannot be referenced from static context

  29. 29

    non-static method matcher(CharSequence) cannot be referenced from a static context

HotTag

Archive