Android Error [Attempt to invoke virtual method 'void android.app.ActionBar' on a null object reference]

后端 未结 24 1953
误落风尘
误落风尘 2020-11-28 22:13

I have a code module which implements viewpager with navigation drawer, however, when I run the code I get the following error

01-26 09:20:02.958: D/AndroidR         


        
24条回答
  •  [愿得一人]
    2020-11-28 22:40

    I got the same error once, I created a template for a default toolbar( toolbar.xml) and then in another view I created a collapsable toolbar.

    I required to add the collapsable toolbar to a view that show some information of the user(like whatsapp), but the method findViewById was referencing the default toolbar(id toolbar), not the collapsable one( id toolbar as well) yes, I wrote the same id to both toolbar, so when I tried to access the activity the app crashed showing me the error.

    I fixed the error by changing the id of the collapsable toolbar to id:col_toolbar and the error gone away and my app worked perfectly

提交回复
热议问题