NoSuchMethodError error for getActionBar() (API-8)

后端 未结 6 1966
醉酒成梦
醉酒成梦 2020-12-17 09:59

when i run the app it installs but then crashes, ecplise isnt telling there is anything wrong with my code. i think its a problem with my manifest...



        
6条回答
  •  天涯浪人
    2020-12-17 10:57

    This is because the getActionBar is a method of api 11, but you can do this:

    if (android.os.Build.VERSION.SDK_INT >= 11)
        getActionBar().setDisplayHomeAsUpEnabled(true); //example
    

    and in the activity class add this suppress Lint:

    @SuppressLint("NewApi")
    

提交回复
热议问题