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

后端 未结 24 1980
误落风尘
误落风尘 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:45

    I think what you want to do is cast getActivity(). For example:

    ((AppCompatActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    This is what you need to do with the new support libraries. AppCompatActivity has replaced ActionBarActivity.

提交回复
热议问题